Programming languages have different ways of expressing floating-point literals.



Task

Show how floating-point literals can be expressed in your language: decimal or other bases, exponential notation, and any other special features.

You may want to include a regular expression or BNF/ABNF/EBNF defining allowable formats for your language.



Related tasks

   Literals/Integer
   Extreme floating point values


//    Floating-point Literals: 
//
//    If present,the exponent must be of the form: 
//
//         eNNN...N
//         ENNN...N
//         e-NNN...N
//         E-NNN...N
//         e+NNN...N
//         E+NNN...N
//
//    If present, length suffix must be:
//
//         f     F               (FLOAT64_T)
//         f32   F32             (FLOAT32_T)
//         f64   F64             (FLOAT64_T)
//         fd    Fd   fD   FD    (FLOATD_T) -- boost::multiprecision::
//                                             cpp_dec_float<100, int64_t>
//
//    The presence of "." "E" "e" "F" or "f" indicates a floating point literal. 
// 
//    A literal can start with "-"  "."  or a decimal digit, but not "+" or "_". 
//    There must be at least one digit, so forms like ".F" ".e+11_f32" or just "."
//    are not recognized as floating point literals.
//
//    Floating-point literal examples: 
 
@SAY   0.       .0       0.0      1.        .1       123.123                         ;// FLOAT64_T
@SAY  -0.      -.0      -0.0     -1.       -.1      -123.123                         ;// FLOAT64_T
 
@SAY  -0.E1    .0e0     0.0E6    -1.e6     -.1E8     12.12e44     -0E0     1e20      ;// FLOAT64_T
@SAY  -0.e+1   .0E+0    0.0e+6   -1.E+6    -.1e+8    12.12E+44    -0e+0    1E+20     ;// FLOAT64_T
@SAY  -0.E-1   .0e-0    0.0E-6   -1.e-6    -.1E-8    12.12e-44    -0E-0    1e-20     ;// FLOAT64_T
@SAY  -0E9999999999999999  .0e+9999999999  0.E-999999999999999999                    ;// FLOAT64_T 
@SAY  -8e0000000000000299  .6E+0000000299  5.e-000000000000000299                    ;// FLOAT64_T  
 
@SAY   0f   -0f   0F   -0f   .0F   -1234f     12.F     12.34f                        ;// FLOAT64_T
@SAY   0F32 -0f32 0f32 -0f32 .0f32 -1234F32   12.f32   12.34F32                      ;// FLOAT32_T
@SAY   0f64 -0f64 0F64 -0f64 .0F64 -1234f64   12.F64   12.34f64                      ;// FLOAT64_T
@SAY   0fD  -0fd  0FD  -0fd  .0Fd  -1234fD    12.FD    12.34fD                       ;// FLOATD_T
 
@SAY  -0.E1f    .0e0F    0.0E6f64  -1.e6F64  -.1E8f    12.12e44f64  -0E0F    1e20f64 ;// FLOAT64_T
@SAY  -0.e+1f32 .0E+0F32 0.0e+6f32 -1.E+6F32 -.1e+8f32 12.12E+34F32 -0e+0f32 1E+20F32;// FLOAT32_T
@SAY  -0.E-1fd  .0e-0fD  0.0E-6Fd  -1.e-6FD  -.1E-8fd  12.12e-44fD  -0E-0Fd  1e-20FD ;// FLOATD_T
@SAY  -0E9999999999999999f32 .0e+9999999999F32    0.E-999999999999999999f32          ;// FLOAT32_T 
@SAY  -8e0000000000000299f   .6E+0000000299f64    5.e-00000000000000000000299F64     ;// FLOAT64_T 
@SAY  -8e9999999999999999fD  .6E+99999999999fD    5.e-12345678987654321FD            ;// FLOATD_T  
 
//  note: _ (underscores) can appear in the main numeric part of the literal 
//        after the first digit and before any length suffix: 
 
@SAY   -10_000__f    1__0._55__    -1__.__   .0___44    1_._2__E-23F32 debug:;    
 
//        Underscores can also appear in the exponent, after the first digit:
 
@SAY -1_E-0__2_f32     1.e+0___5_5____   -1.0_E123_456_789_987_654_321__fD debug:;