next up previous
Next: Finding the successor Up: Ordinal Types. Previous: Characters can have

Finding the ordinal value of a character using ord().

To find the ordinal value of a character we use the predefined Pascal function ord().

eg.

        VAR Code:integer;
        ...
        Code := ord('B');

This will give Code the value 66 by looking up the ASCII table. Note: the character is in quotes as always, if it weren't we'd be referring to a variable.

The ordinal values of an integer is the same as the integer's values. ie. the ord(8) is 8,ord(-8) is -8 and ord(0) is 0.

The ordinal value of a boolean value is 1 for ord(true) and 0 for ord(false).



Madhu Nayakkankuppam
Thu Jan 21 17:49:55 EST 1999