Numberio is a library for reading and writing numerals (integers, based integers, radix integers, and reals). The format of these numerals corresponds directly to the format of these numerals as defined by the BETA language (except for radix integers that are not supported by the BETA language). Numberio also contains a general getNumber operation, that is able to read any numeral, and return the proper value read.
Grammar for getNumber operation
The following grammar defines the exact syntax of the numerals:
N ::= D+ int 314 | D+ '.' D+ real 3.14 | D+ '.' D+ 'E' E real 3.14E8 real 3.14E+8 real 3.14E-8 | D+ 'E' E real 3E8 real 3E+8 real 3E-8 | D+ 'X' (D|L)+ based 2X0101 based 8x0845 based 16xAF12 | (D|L)+ radix AF12 D ::= '0' | ... | '9' L ::= 'A' | ... | 'Z' E ::= D+ | '+' D+ | '-' D+
10 0 123
A based integer has the form <base>X<number>. Examples are:
2X101 base=2, number= 4*1 + 2*0 + 1*1 = 5 8X12 base=8, number= 8*1 + 1*2 = 10 16x2A1 base=16, number= 256*2 + 16*10 + 1*1 = 673 0x2A1 base=16, i.e. base=0 is interpreted as base=16
Examples of reals are:
3.14 3.14E-8 3E+8
All letters may be in lower or upper case.
The various read and write operations contain several facilities for controlling the read and write. Please consult the interface description later for details.
|Basic Libraries - Reference Manual||© 1990-2002 Mjølner Informatics||
[Modified: Friday January 4th 2002 at 13:10]