TOML has good support to represent real numbers.
floatDemo.toml
a = 1.23
b = 0.0
c = -0.0
d = -1.234
TOML support exponential notation
You can write the float numbers in exponential notation also.
floatDemo2.toml
a = 123e-2
b = 12.3e-1
c = 123e2
d = 12.3e3
Above snippet is equivalent to following json.
{
"a": 1.23,
"b": 1.23,
"c": 12300,
"d": 12300
}
Use _ to enhance readability
You can use _ to enhance the readability of a number.
pi = 3.14_15
Special values like Inifinity and NaN are supported
Special float values are always expressed in lower case.
specialFloatValues.toml
# infinity
a = inf # positive infinity
b = +inf # positive infinity
c = -inf # negative infinity
# not a number
d = nan # encoding is implementation-specific
e = +nan # same as `nan`
f = -nan # actual encoding is implementation-specific
No comments:
Post a Comment