Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jan 17, 2017

Use Float.parseFloat instead of converting from Double.
Error when a value rounds to zero.

JIRA: https://issues.scala-lang.org/browse/SI-10148

@scala-jenkins scala-jenkins added this to the 2.12.2 milestone Jan 17, 2017
Use `Float.parseFloat` instead of converting from Double.
Error when a value rounds to zero.
check_success("1.00000017881393421514957253748434595763683319091796875001f == 1.0000001f",
1.00000017881393421514957253748434595763683319091796875001f,
1.0000001f)
check_success("3.4028235E38f == Float.MaxValue", 3.4028235E38f, Float.MaxValue)
Copy link
Member

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!

Copy link
Contributor Author

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.

Copy link
Member

@janekdb janekdb Jan 18, 2017

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?

Copy link
Contributor Author

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.

@adriaanm adriaanm requested a review from SethTisue February 16, 2017 20:34
@SethTisue SethTisue merged commit 955b779 into scala:2.12.x Feb 16, 2017
@SethTisue
Copy link
Member

thx AP!

@som-snytt som-snytt deleted the issue/10148 branch February 16, 2017 22:25
@SethTisue
Copy link
Member

this turned up in the community build:

[breeze] [error] /Users/tisue/community.212/target-0.9.7-RC1/project-builds/breeze-ef73d8d5e54fa4ff81b6f6abfe9e238739cc5d8a/math/src/test/scala/breeze/signal/filter/DesignFilterTest.scala:53: double precision floating point number too small
[breeze] [error]   val testFirwin4 = DenseVector( -0.000000000000000000e+00, 3.794040820411270776e-01, 3.794040820411272441e-01, -0.000000000000000000e+00)
[breeze] [error]                                   ^
[breeze] [error] /Users/tisue/community.212/target-0.9.7-RC1/project-builds/breeze-ef73d8d5e54fa4ff81b6f6abfe9e238739cc5d8a/math/src/test/scala/breeze/signal/filter/DesignFilterTest.scala:53: double precision floating point number too small
[breeze] [error]   val testFirwin4 = DenseVector( -0.000000000000000000e+00, 3.794040820411270776e-01, 3.794040820411272441e-01, -0.000000000000000000e+00)
[breeze] [error]                                                                                                                  ^
[breeze] [error] two errors found

is this a regression, or is the code in breeze erroneous...?

@som-snytt
Copy link
Contributor Author

Zero is pretty small. It looks like the little heuristic for testing whether you said zero is not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants