Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scientific notation for floats & allow optional + prefix on integers. #13

Open
pnathan opened this issue Nov 10, 2014 · 1 comment

Comments

@pnathan
Copy link
Owner

pnathan commented Nov 10, 2014

+A float consists of an integer part (which may be prefixed with a plus or minus
+sign) followed by a fractional part and/or an exponent part. If both a
+fractional part and exponent part are present, the fractional part must precede
+the exponent part.

+A fractional part is a decimal point followed by one or more digits.
+
+An exponent part is an E (upper or lower case) followed by an integer part
+(which may be prefixed with a plus or minus sign).
+
+64-bit (double) precision expected.

---
+# fractional
++1.0
 3.1415
 -0.01
+
+# exponent
+5e+22
+1e6
+-2E-2
+
+# both
6.626e-34
@pnathan pnathan added this to the TOML v0.3.0 milestone Nov 10, 2014
@pnathan pnathan removed this from the TOML v0.3.0 milestone Oct 9, 2021
@pnathan
Copy link
Owner Author

pnathan commented Oct 9, 2021

Floats should be implemented as IEEE 754 binary64 values.

A float consists of an integer part (which follows the same rules as decimal integer values) followed by a fractional part and/or an exponent part. If both a fractional part and exponent part are present, the fractional part must precede the exponent part.

fractional

flt1 = +1.0
flt2 = 3.1415
flt3 = -0.01

exponent

flt4 = 5e+22
flt5 = 1e06
flt6 = -2E-2

both

flt7 = 6.626e-34
A fractional part is a decimal point followed by one or more digits.

An exponent part is an E (upper or lower case) followed by an integer part (which follows the same rules as decimal integer values but may include leading zeros).

The decimal point, if used, must be surrounded by at least one digit on each side.

INVALID FLOATS

invalid_float_1 = .7
invalid_float_2 = 7.
invalid_float_3 = 3.e+20
Similar to integers, you may use underscores to enhance readability. Each underscore must be surrounded by at least one digit.

flt8 = 224_617.445_991_228
Float values -0.0 and +0.0 are valid and should map according to IEEE 754.

Special float values can also be expressed. They are always lowercase.

infinity

sf1 = inf # positive infinity
sf2 = +inf # positive infinity
sf3 = -inf # negative infinity

not a number

sf4 = nan # actual sNaN/qNaN encoding is implementation-specific
sf5 = +nan # same as nan
sf6 = -nan # valid, actual encoding is implementation-specific

@pnathan pnathan added this to the Support TOML v1.0 milestone Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant