Gentee Programming Language > Documentation > Syntax Download documentation

Numbers

Actually, in the language natural numbers are denoted by:

a decimal number, that is based on the decimal digits.
<decimal number> ::= <decimal digit> {<decimal digit>}

a hexadecimal number, that is based on hex digits. To specify the hexadecimal number, start the hexadecimal number with - '0x' or '0X'.
<hexadecimal number> ::= '0' ('x' | 'X') <hexadecimal number> {<hexadecimal number>}

a binary number, that is based on binary digits. To specify the binary number, start the binary number with - '0b' or '0B'.
<binary number> ::= '0' ('b' | 'B') <binary number> {<binarynumber>}

number-a character code is a number that represents a particular character enclosed in single quote marks, i.e it is equal to the ANSI character code.
<character code> ::= '''<any character>'''

Natural numbers are decimals, hexadecimal numbers and character codes.
<natural number> ::= <decimal number> | <hexadecimal number> | <binary number> | <character code>

The following example illustrates a number expressed in different ways:

65     //  a decimal
0x41 // a hexadecimal number = 65
'A' // a character code = 65

Some language constructions apply a number denoted by a byte, i.e. numbers from 0 to 255 furthermore, these are only numbers in hexadecimal notation in a range from 00 to FF.

<byte> := <hexadecimal digit><hexadecimal digit>

Integer constants can be preceded by a minus sign '–'.
<integer number> ::= ['-'] <natural number> ['l' | 'L']

Type long is assigned by appending the letter L to the end of the integer constant.

There are two types of real numbers: double and float. A real number of the double type contains a decimal point or a mantissa. The letter F is appended to the end of the constant to make float. Type double might be denoted by the letter D appended to the end of the constant.
<floating point number> ::= <decimal number>'.'[<decimal number>]
<real number> ::= ['-'] (<floating point number> | <floating point number> ('e' | 'E') ['+' | '-'] <decimal number>) ['d' | 'D']

123.122   //  the floating-point number 
-123.2å-2 // the number with a mantissa
12D
12.34F // the number of type float

<number> := <integer number> | <floating point number> | <real number>

See also

    Built-In Data Types


 Copyright © 2004-2006 Gentee Inc. All rights reserved.