// sign = "+" | "-" .
// prefix = "0" ( "x" | "X" | "b" | "B" ) .
// mantissa = digits | digits "." [ digits ] | "." digits .
-// exponent = ( "E" | "e" | "p" ) [ sign ] digits .
+// exponent = ( "e" | "E" | "p" | "P" ) [ sign ] digits .
// digits = digit { digit } .
// digit = "0" ... "9" | "a" ... "z" | "A" ... "Z" .
// infinity = [ sign ] ( "inf" | "Inf" ) .
// The octal prefix "0" is not supported (a leading "0" is simply
// considered a "0").
//
-// A "p" exponent indicates a binary (rather then decimal) exponent;
+// A "p" or "P" exponent indicates a binary (rather then decimal) exponent;
// for instance "0x1.fffffffffffffp1023" (using base 0) represents the
// maximum float64 value. For hexadecimal mantissae, the exponent must
// be binary, if present (an "e" or "E" exponent indicator cannot be
{"0b001p-3", 0.125},
{"0b.001p3", 1},
{"0b0.01p2", 1},
+ {"0b0.01P+2", 1},
// hexadecimal mantissa and exponent
{"0x0", 0},
{"0xff", 255},
{"0X.8p1", 1},
{"-0X0.00008p16", -0.5},
+ {"-0X0.00008P+16", -0.5},
{"0x0.0000000000001p-1022", math.SmallestNonzeroFloat64},
{"0x1.fffffffffffffp1023", math.MaxFloat64},
} {
}
// scanExponent scans the longest possible prefix of r representing a decimal
-// ('e', 'E') or binary ('p') exponent, if any. It returns the exponent, the
-// exponent base (10 or 2), or a read or syntax error, if any.
+// ('e', 'E') or binary ('p', 'P') exponent, if any. It returns the exponent,
+// the exponent base (10 or 2), or a read or syntax error, if any.
//
-// exponent = ( "E" | "e" | "p" ) [ sign ] digits .
+// exponent = ( "e" | "E" | "p" | "P" ) [ sign ] digits .
// sign = "+" | "-" .
// digits = digit { digit } .
// digit = "0" ... "9" .
switch ch {
case 'e', 'E':
// ok
- case 'p':
+ case 'p', 'P':
if binExpOk {
base = 2
break // ok