Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
Real Number FormattingThere are multiple formats for textual representation of real numbers Scientific format, defined by the following EBNF:sciReal : ( '+' | '-' )? decimalDigit '.' digitGroup ( ',' digitGroup )* scaleFactor ; digitGroup : decimalDigit decimalDigit decimalDigit ; scaleFactor : ( '+' | '-') decimalDigit+ ; decimalDigit : '0' .. '9' ; Example: 1.234,567,890E+00 Formatting parameters:
Engineering format, defined by the following EBNF:engReal : ( '+' | '-' )? decimalDigit decimalDigit? decimalDigit? ( ',' digitGroup )* '.' digitGroup ( ',' digitGroup )* scaleFactor ; digitGroup : decimalDigit decimalDigit decimalDigit ; scaleFactor : ( '+' | '-') decimalDigit+ ; decimalDigit : '0' .. '9' ; The numeric value of Example: 1,234.567,890E+03 Formatting parameters:
Ledger format, defined by the following EBNF:ledgerReal : ( '+' | '-' )? whitespace* decimalDigit decimalDigit? decimalDigit? ( ',' digitGroup )* ( '.' decimalDigits+ )? digitGroup : decimalDigit decimalDigit decimalDigit ; decimalDigit : '0' .. '9' ; Examples: 1,234,567.00 or 1,234,567 Formatting parameters:
Simple format, defined by the following EBNF:simpleReal : ( '+' | '-' )? decimalDigit+ ( '.' decimalDigits+ )? decimalDigit : '0' .. '9' ; Examples: 123456.7890 or 123456 Formatting parameters:
IO Procedures for Real Number typesThe standard IO library shall provide the following output procedures for every real number type that is provided by the language core or by the standard library. It shall be recommended that user libraries implementing real number types also provide these procedures.
shall produce output in scientific format with 9 places after the decimal point.
shall produce output in scientific format with n places after the decimal point.
shall produce output in engineering format with n places before, m places after the decimal point and exponent exp, whereby parameters m and exp shall be rounded to the nearest multiple of three.
shall produce output in ledger format with the decimal point at index i and n places after the decimal point.
shall produce output in simple format with the decimal point at index i and n places after the decimal point. Mapping of WRITE and WRITEF macrosThe compiler shall expand the WRITE and WRITEF macros when invoked with a real number argument as follows:
whereby Affected Types
|