Hexadecimal Literals

A number sign (#) precedes a hexadecimal (hex) value. You can define literal hexadecimal integer, string, character, or binary values.

Hexadecimal strings in JADE are represented as a sequence of space-separated hexadecimal characters.

The following example illustrates the use of string and integer hexadecimal literals in defining a series of constants.

constants
    WhiteSpace = #"09 0A 0B 0C 0D 20";
    MaxInt     = #7FFFFFFF;
    MaxInt16   = #FFFF;
    BitMask01  = #55555555;

To define a binary hexadecimal literal value, enclose a sequence of space-separated hexadecimal characters in bracket symbols ([]). For example:

DaysInMonth = #[1F 1C 1F 1E 1F 1E 1F 1F 1E 1F 1E 1F];

The following daysInMonth method of the Integer primitive type provides an example of the use of a binary hexadecimal literal to return the number of days in the specified month. This method expects a Boolean parameter advising if the year in question is a leap year.

daysInMonth(isLeapYear: Boolean): Integer;
constants
    //construct a compile-time value array
    DaysInMonth = #[1F 1C 1F 1E 1F 1E 1F 1F 1E 1F 1E 1F];
begin
    if self = 2 and isLeapYear then
        return 29;
    endif;
    return DaysInMonth[self];
end;