1.6 Numbers

Numbers are by default denoted in decimal notation. Real (or decimal) numbers are written using engineering or scientic notation (e.g. 0.314E1).

For integer type constants, Free Pascal supports 4 formats:

  1. Normal, decimal format (base 10). This is the standard format.
  2. Hexadecimal format (base 16), in the same way as Turbo Pascal does. To specify a constant value in hexadecimal format, prepend it with a dollar sign ($). Thus, the hexadecimal $FF equals 255 decimal. Note that case is insignicant when using hexadecimal constants.
  3. As of version 1.0.7, Octal format (base 8) is also supported. To specify a constant in octal format, prepend it with a ampersand (&). For instance 15 is specied in octal notation as &17.
  4. Binary notation (base 2). A binary number can be specied by preceding it with a percent sign (%). Thus, 255 can be specied in binary notation as %11111111.

The following diagrams show the syntax for numbers.

_________________________________________________________________________________________________________Numbers
-- --hex digit sequence-hex digit--------------------------------------
                     6--------|

-- --               ---        -------------------------------------
     octal digit sequence 6octal digit

-- --              ----  -------------------------------------------
     bin digit sequence 6-10 -||
                     ------|

-- --           ---    --------------------------------------------
     digit sequence 6digit-|

-- --unsigned integer|----digit sequence-------------------------------
                   |-$--hex digit sequence|
                     %  bin digit sequence

-- --sign|+ --------------------------------------------------------
        -----

-- --unsigned real digit sequence -|-----------------|-------------------
                              -.-digit sequence- -scale factor--

-- --scale factor--E ----------digit sequence---------------------------
                -e -| -sign--|

-- --unsigned number---unsigned real----------------------------------
                    -unsigned integer-|

-- --           ---------              ----------------------------
     signed number -    -| unsigned number
                   sign
___________________________________________________________________

Remark: All decimal constants which do no t within the -2147483648..2147483647 range are silently and automatically parsed as 64-bit integer constants as of version 1.9.0. Earlier versions would convert it to a real-typed constant.

Remark: Octal and Binary notation are not supported in TP or Delphi compatibility mode.