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


 
> 123.456; # decimal notation
                                123.456
 
> 1.23456e2; # scientific notation
                                123.456
 
> Float( 23, -2 ); # float constructor notation, by mantissa and exponent
                                  0.23
 
> Float( .123456, 3 ); # again
                                123.456
 
> Float( 1.23456, 2 ); # again
                                123.456
 
> Float( 12.3456, 1 ); # again
                                123.456
 
> HFloat( 1.23456, 2 ); # hardware float constructor
                            123.456000000000
 
> HFloat( 123.456 ); # again
                            123.456000000000
 
> 2.3^30; # large floats are printed using scientific notation
                                          11
                           0.7109434879 10
 
> 2/3; # NOT a float!
                                  2/3
 
> evalf( 2/3 ); # but you can get one
                              0.6666666667
 
> 0.0; # zero
                                   0.
 
> -0.0; # negative zero
                                  -0.
 
> Float(infinity); # positive infinity
                            Float(infinity)
 
> Float(-infinity); # minus infinity
                            Float(-infinity)
 
> Float(undefined); # "NaN", not-a-number
                            Float(undefined)
 