design/19308-number-literals: adjust hex_float_lit and imaginary_lit syntax
We permit a _ separator after the hex prefix in a hexadecimal
integer, as in 0x_1234; for consistency we also allow the
separator in a hexadecimal float, as in 0x_1234.0p0.
Also, to limit imaginary literals to decimal representations
as is the case now, change the repespective syntax to refer
to decimal_float_lit rather than float_lit (which now also
permits hexadecimal float representations).
Change-Id: I03d95dffe3d583dad862b4f75e998aa0772f39a2
Reviewed-on: https://go-review.googlesource.com/c/158862
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/design/19308-number-literals.md b/design/19308-number-literals.md
index da877be..3375a48 100644
--- a/design/19308-number-literals.md
+++ b/design/19308-number-literals.md
@@ -3,7 +3,7 @@
Russ Cox\
Robert Griesemer
-Last updated: January 16, 2019
+Last updated: January 23, 2019
[golang.org/design/19308-number-literals](https://golang.org/design/19308-number-literals)
@@ -344,8 +344,8 @@
> "." decimals [ exponent ] .
> decimals = decimal_digit { [ "_" ] decimal_digit } .
> exponent = ( "e" | "E" ) [ "+" | "-" ] decimals .
-> hex_float_lit = hex_prefix hex_digits "." [ hex_digits ] hex_exponent |
-> hex_prefix hex_digits hex_exponent |
+> hex_float_lit = hex_prefix [ "_" ] hex_digits "." [ hex_digits ] hex_exponent |
+> hex_prefix [ "_" ] hex_digits hex_exponent |
> hex_prefix "." hex_digits hex_exponent .
> hex_prefix = "0" ( "x" | "X" ) .
> hex_digits = hex_digit { [ "_" ] hex_digit } .
@@ -364,6 +364,7 @@
> 0x2.p10 // == 2048.0
> 0x1.Fp+0 // == 1.9375
> 0X.8p-0 // == 0.5
+> 0X_1FFFP-16 // == 0.1249847412109375
> 0x.p1 // illegal: must have hex digit
> 1p-2 // illegal: p exponent requires hexadecimal mantissa
> 0x1.5e-2 // illegal: hexadecimal mantissa requires p exponent
@@ -376,6 +377,11 @@
> 1.5e_1 // illegal: _ must separate digits
> 1.5e1_ // illegal: _ must separate digits
+The syntax in https://golang.org/ref/spec#Imaginary_literals section would be amended to read:
+
+
+> imaginary_lit = (decimals | decimal_float_lit) .
+
### Library Changes
In [`fmt`](https://golang.org/pkg/fmt/),