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
SI-10148 Follow Java for float literals #5648
Conversation
Use `Float.parseFloat` instead of converting from Double. Error when a value rounds to zero.
0f58c48
to
a262aab
Compare
check_success("1.00000017881393421514957253748434595763683319091796875001f == 1.0000001f", | ||
1.00000017881393421514957253748434595763683319091796875001f, | ||
1.0000001f) | ||
check_success("3.4028235E38f == Float.MaxValue", 3.4028235E38f, Float.MaxValue) |
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.
Why no check using Float.MinValue? Probably demonstrating my ignorance of something here!
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.
My name isn't ScalaCheck. Also, the difference is just a sign bit which is turned on by a leading midlevel horizontal bar symbol. Of course, the test wouldn't hurt.
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.
Ignorance of IEEE 754 fully demoed (by me)! Java MIN_VALUE is not the negative float with the greatest magnitude but the smallest positive nonzero value.
https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#MIN_VALUE
Having said that why not add a check for the effect of a leading hyphen-minus
?
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.
OK, if I have time to switch my repo back to this branch on my old home machine.
There's a puzzler (BTW) that turns on the fact that -1.0f
is a literal. See here.
thx AP! |
this turned up in the community build:
is this a regression, or is the code in breeze erroneous...? |
Zero is pretty small. It looks like the little heuristic for testing whether you said zero is not right. |
Use
Float.parseFloat
instead of converting from Double.Error when a value rounds to zero.
JIRA: https://issues.scala-lang.org/browse/SI-10148