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


;;Numeric literals with a decimal component are treated as floating point.
3.14159           ;3.14159
 
;;An exponent can be specified via "e" or "E" and is always floating point.
2.3456e7          ;23456000.0
 
;;Hexadecimal literals are supported, including exponents via "p" or "P".
0x1234.abcd       ;4660.6710968018
0x1234.56p3       ;37282.6875
 
;;Underscores can optionally be used to split numbers into readable chunks.
123_456.789       ;123456.789
0x1234_5678.9a    ;305419896.60156