@@ -776,7 +776,7 @@ $(GNAME HexLetter):
776
776
by a $(SINGLEQUOTE 0x) or $(SINGLEQUOTE 0X).
777
777
)
778
778
779
- $(P Integers can have embedded $(SINGLEQUOTE $(UNDERSCORE)) characters to improve readability, and which are ignored.
779
+ $(P Integers can have embedded $(SINGLEQUOTE $(UNDERSCORE)) characters after a digit to improve readability, which are ignored.
780
780
)
781
781
782
782
---
@@ -831,23 +831,18 @@ $(H2 $(LNAME2 floatliteral, Floating Point Literals))
831
831
832
832
$(GRAMMAR_LEX
833
833
$(GNAME FloatLiteral):
834
- $(GLINK Float)
835
- $(GLINK Float) $(GLINK Suffix)
836
- $(GLINK Integer) $(GLINK FloatSuffix)
837
- $(GLINK Integer) $(GLINK ImaginarySuffix)
838
- $(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)
839
- $(GLINK Integer) $(GLINK RealSuffix) $(GLINK ImaginarySuffix)
834
+ $(GLINK Float) $(GLINK Suffix)$(OPT)
835
+ $(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)$(OPT)
836
+ $(GLINK Integer) $(GLINK RealSuffix)$(OPT) $(GLINK ImaginarySuffix)
840
837
841
838
$(GNAME Float):
842
839
$(GLINK DecimalFloat)
843
840
$(GLINK HexFloat)
844
841
845
842
$(GNAME DecimalFloat):
846
- $(GLINK LeadingDecimal) $(B .)
847
- $(GLINK LeadingDecimal) $(B .) $(GLINK DecimalDigitsNoStartingUS)
843
+ $(GLINK LeadingDecimal) $(B .) $(GLINK DecimalDigitsNoStartingUS)$(OPT)
848
844
$(GLINK LeadingDecimal) $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
849
- $(B .) $(GLINK DecimalDigitsNoStartingUS)
850
- $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
845
+ $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)$(OPT)
851
846
$(GLINK LeadingDecimal) $(GLINK DecimalExponent)
852
847
853
848
$(GNAME DecimalExponent):
@@ -883,11 +878,9 @@ $(GNAME HexExponentStart):
883
878
884
879
885
880
$(GNAME Suffix):
886
- $(GLINK FloatSuffix)
887
- $(GLINK RealSuffix)
881
+ $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)$(OPT)
882
+ $(GLINK RealSuffix) $(GLINK ImaginarySuffix)$(OPT)
888
883
$(GLINK ImaginarySuffix)
889
- $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)
890
- $(GLINK RealSuffix) $(GLINK ImaginarySuffix)
891
884
892
885
$(GNAME FloatSuffix):
893
886
$(B f)
@@ -896,22 +889,42 @@ $(GNAME FloatSuffix):
896
889
$(GNAME RealSuffix):
897
890
$(B L)
898
891
899
- $(GNAME ImaginarySuffix):
892
+ $(GDEPRECATED $( GNAME ImaginarySuffix) ):
900
893
$(B i)
901
894
902
895
$(GNAME LeadingDecimal):
903
896
$(GLINK DecimalInteger)
904
897
$(B 0) $(GLINK DecimalDigitsNoSingleUS)
905
898
)
906
899
907
- $(P Floats can be in decimal or hexadecimal format.)
900
+ $(P Floats can be in decimal or hexadecimal format, and must have
901
+ at least one digit and either a decimal point, an exponent, or
902
+ a *FloatSuffix*.)
903
+
904
+ $(P Decimal floats can have an exponent which is `e` or `E` followed
905
+ by a decimal number serving as the exponent of 10.)
906
+
907
+ ---
908
+ -1.0
909
+ 1e2 // 100.0
910
+ 1e-2 // 0.01
911
+ -1.175494351e-38F // float.min
912
+ ---
908
913
909
914
$(P Hexadecimal floats are preceded by a $(B 0x) or $(B 0X) and the
910
915
exponent is a $(B p) or $(B P) followed by a decimal number serving as
911
916
the exponent of 2.
912
917
)
913
918
914
- $(P Floating literals can have embedded $(SINGLEQUOTE $(UNDERSCORE)) characters to improve readability, and which are ignored.
919
+ ---
920
+ 0xAp0 // 10.0
921
+ 0x1p2 // 4.0
922
+ 0x1.FFFFFFFFFFFFFp1023 // double.max
923
+ 0x1p-52 // double.epsilon
924
+ ---
925
+
926
+ $(P Floating literals can have embedded $(D $(UNDERSCORE)) characters
927
+ after a digit to improve readability, which are ignored.
915
928
)
916
929
917
930
---
@@ -921,24 +934,21 @@ $(GNAME LeadingDecimal):
921
934
6_022_.140_857E+20_
922
935
---
923
936
924
- $(P Floating literals with no suffix are of type `double`.
925
- Floating literals followed by $(B f) or $(B F) are of type `float`,
926
- and those followed by $(B L) are of type `real`.
927
- )
928
-
929
- $(P Examples:)
937
+ * Floating literals with no suffix are of type `double`.
938
+ * Floating literals followed by $(B f) or $(B F) are of type `float`.
939
+ * Floating literals followed by $(B L) are of type `real`.
930
940
931
941
---------
932
- 0x1.FFFFFFFFFFFFFp1023 // double.max
933
- 0x1p-52 // double.epsilon
934
- 1.175494351e-38F // float.min
942
+ 0.0 // double
943
+ 0F // float
944
+ 0.0L // real
935
945
---------
936
946
937
947
$(P The literal may not exceed the range of the type.
938
948
The literal is rounded to fit into
939
949
the significant digits of the type.
940
950
)
941
- $(P If a floating literal has a $(B .) and a type suffix, at least one
951
+ $(P If a floating literal has a $(D .) and a type suffix, at least one
942
952
digit must be in-between:)
943
953
944
954
---
@@ -947,7 +957,7 @@ $(GNAME LeadingDecimal):
947
957
1.; // OK, double
948
958
---
949
959
950
- $(P NOTE: Floating literals followed by $(B i) to denote imaginary
960
+ $(NOTE Floating literals followed by $(B i) to denote imaginary
951
961
floating point values have been deprecated.)
952
962
953
963
0 commit comments