Sign in Join
FPDoc Onlineexperiment

Hi function

In unit System

Return high byte/word/nibble of value.

Declaration

pascal
function Hi(b: Byte): Byte

Description

Hi returns the high nibble, byte or word or longword from X, depending on the size of X.

Size Return value
8 Byte, High nibble
16 Byte, High byte
32 Word, High word
64 Cardinal, High DWord

Note that in Delphi or TP, this function always treats its argument as if it was a Word, so the results may differ from FPC.

Errors

None.

See also

Example: ex31

pascal
Program Example31;

{ Program to demonstrate the Hi function. }

var
  L : Longint;
  W : Word;
  B : Byte;
  
begin
  L:=1 Shl 16;     { = $10000 }
  W:=1 Shl 8;      { = $100 }
  B:=1 Shl 4;      { = $10  }
  Writeln (Hi(L)); { Prints 1 }
  Writeln (Hi(W)); { Prints 1 }
  Writeln (Hi(B)); { Prints 1 }
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.