Integer literal expressions

Sather - Language Specification
Prev | Chapter 6. Literal Expressions | Next

# 6.4. Integer literal expressions

Example 6-5. Examples:

    14
    14i
    -4532
    39_832_983_298
    0b101011
    -0b_10111010_00101100_01010101
    0o372363i
    0x_e98a_7c4d_65d7_6aa6_932d

    int_literal_expression ==>
            [-] (binary_int | octal_int | decimal_int | hex_int) [i]

    binary_int ==>
            0b {binary_digit | _}

    binary_digit ==>
            0 | 1

    octal_int ==>
            0o {octal_digit | _}

    octal_digit ==>
            0 | 1 | 2 | 3 | 4 | 5 | 6 | 7

    decimal_int ==>
            decimal_digit {decimal_digit | _}

    hex_int ==>
            0x {hex_digit | _}

    hex_digit ==>
            decimal_digit | a | b | c | d | e | f

INT objects represent machine integers and INTI objects represent infinite precision integers (See Type). The literal form for INTI objects ends with a trailing 'i'. A leading '-' sign is used to denote a negative integer. Integer literals can be represented in four bases: binary is base 2, octal is base 8, decimal is base 10 and hexadecimal is base 16. These are indicated by the prefixes: '0b', '0o', nothing, and '0x' respectively. Underscores may be used within integer literals to improve readability and are ignored. INT literals are only legal if they are in the representable range of the Sather implementation, which is at least 32 bits (See Type).

Prev | Home | Next
String literal expressions | Up | Floating point literal expressions