-
Notifications
You must be signed in to change notification settings - Fork 859
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 non-finite floats and clarify signed zeros #506
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Values such as "infinity" and "not a number" that cannot be expressed as a | ||
series of digits are not allowed. | ||
Leading zeros are not allowed. Integer values `-0` and `+0` are valid and | ||
identical to an unprefixed zero. Hex, octal, and binary forms are not allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#409?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, one thing at a time!
README.md
Outdated
|
||
64 bit (signed long) range expected (−9,223,372,036,854,775,808 to | ||
9,223,372,036,854,775,807). | ||
|
||
Float | ||
----- | ||
|
||
Floats should be implemented as 64-bit IEEE 754 values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should say IEEE 754 binary64 values, since there's a 64-bit decimal64 as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fair enough, will change.
README.md
Outdated
nf1 = +inf # positive infinity | ||
nf2 = inf # positive infinity | ||
nf3 = -inf # negative infinity | ||
nf4 = nan # not a number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IEEE 754 has 2 types of NaNs -- sNaN and qNaN.
It might be worthwhile to mention that which one it is would be implementation dependant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and many of each! I'll add a note as you suggest.
toml.abnf
Outdated
@@ -117,14 +117,19 @@ underscore = %x5F ; _ | |||
|
|||
;; Float | |||
|
|||
float = integer ( frac / ( frac exp ) / exp ) | |||
float = integer ( frac / ( frac exp ) / exp ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe now would be a good time to change this to?
float = integer ( exp / frac [ exp ] )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable.
toml.abnf
Outdated
@@ -117,14 +117,19 @@ underscore = %x5F ; _ | |||
|
|||
;; Float | |||
|
|||
float = integer ( frac / ( frac exp ) / exp ) | |||
float = integer ( frac / ( frac exp ) / exp ) | |||
float =/ non-finite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call them "named float values"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a bit of googling, it seems like "special values" is the preferred nomenclature. How does that strike you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see this go as is.
toml.abnf
Outdated
@@ -117,14 +117,19 @@ underscore = %x5F ; _ | |||
|
|||
;; Float | |||
|
|||
float = integer ( frac / ( frac exp ) / exp ) | |||
float = integer ( exp / frac [ exp ] ) | |||
float =/ non-finite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float-special-values
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with just special-float
. values
seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
special-float
works. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll pretend I needed to approve. ;)
@pradyunsg Haha, thanks. =) I'll wait for a few more thoughts from others before final merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, but overall LGTM.
toml.abnf
Outdated
|
||
frac = decimal-point zero-prefixable-int | ||
decimal-point = %x2E ; . | ||
zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT ) | ||
|
||
exp = "e" integer | ||
|
||
special-float = ( [ minus / plus ] inf ) / nan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if allowing ±
in front of nan
also would be simpler – keeping the universal rule that numbers can have a sign prefix. Of course +nan
, nan
and -nan
would all mean the same thing, but it could be simpler. Not a big issue, just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting point. It would keep the consistency across all values, which would be a nice behavior. I suppose if the implementation wanted to, it could carry over the sign to the NaN value, even though it's insignificant, but who knows!
CHANGELOG.md
Outdated
@@ -2,6 +2,7 @@ | |||
|
|||
## HEAD | |||
|
|||
* Add non-finite float values (+inf, inf, -inf, nan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps only list one of +inf
and inf
here – since this says "values" and those are the same value written with different syntaxes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, will tighten in up.
Closes #389.
This adds support for non-finite float values (
-inf
,inf
,+inf
,nan
) and clarifies that signed zeros (integer and float) are valid and what they mean.