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

Scala should have a @Strictfp annotation #1708

Closed
scabug opened this issue Feb 10, 2009 · 10 comments
Closed

Scala should have a @Strictfp annotation #1708

scabug opened this issue Feb 10, 2009 · 10 comments

Comments

@scabug
Copy link

scabug commented Feb 10, 2009

(Jorge Ortiz suggested I file this ticket)

strictfp has been around for over 10 years -- since Java 1.2.
It's important to some scientific users. Supporting strictfp
is part of Scala's capabilities being a superset of Java's.

Most users justifiably don't care, but if you're doing some kinds of
scientific computing, then exact reproducibility of floating point
results cross-platform is important. For example, in our simulation
tool NetLogo, we promise users that if they run their simulation with
the same random seed, they'll get the same results every time, no matter
what computer they're on. This ensures that published simulation
results can be reproduced. And that promise rests on Java's strictfp
promise.

It's also convenient for testing purposes (in any application domain)
not to have to worry about whether results can vary slightly from
machine to machine.

It would certainly be nice if Scala supported strictfp declarations (an
annotation instead of a keyword would be fine. I imagine Java would
java done it that way if annotations existed at the time). I don't have any actual
simulation engine code in Scala right now, but when I do, I guess I'll
have to find a way to post-process the class files generated by scalac
in order to set the strictfp flag myself.

@scabug
Copy link
Author

scabug commented Feb 10, 2009

Imported From: https://issues.scala-lang.org/browse/SI-1708?orig=1
Reporter: @SethTisue

@scabug
Copy link
Author

scabug commented Feb 11, 2009

@dragos said:
Should be easy to implement, here's a short test (taken from http://java.sun.com/developer/JDCTechTips/2001/tt0410.html#using):

public strictfp class FPTest {
    public static void main(String[] args) {
        double d = 8e+307;
        System.out.println(4.0 * d * 0.5);
        System.out.println(2.0 * d);
    }
}

There seems to be no equivalent on .NET, so this will have an effect only on jvm targets.

@scabug
Copy link
Author

scabug commented Jun 18, 2010

@scabug
Copy link
Author

scabug commented Jun 18, 2010

@dragos said:
I need someone else to take care of this.

@scabug
Copy link
Author

scabug commented Jun 18, 2010

@paulp said:
Every supposed @Strictfp illustrating java example I try on OSX java6 or openjdk, I get the same results either way. Not likely I can implement this without being able to see something happen. Requesting assistance: closing NEEDINFO, but anyone who wants to implement it feel free to reopen.

@scabug
Copy link
Author

scabug commented Sep 16, 2010

@SethTisue said:
the way we would "see something happen" if Scala had strictfp support is by looking in the class files output by the compiler and seeing whether the strictfp bit is being set, the same way the Java compiler sets it. it's not necessary to actually test whether you get different answers from math operations; we can assume the JVM will do the right thing there.

I think this ticket should remain open as a requested enhancement. I think assigning it to scala_community would be reasonable.

@scabug
Copy link
Author

scabug commented Sep 16, 2010

@paulp said:
Replying to [comment:6 SethTisue]:

the way we would "see something happen" if Scala had strictfp support is by looking in the class files output by the compiler and seeing whether the strictfp bit is being set, the same way the Java compiler sets it. it's not necessary to actually test whether you get different answers from math operations; we can assume the JVM will do the right thing there.

I think this ticket should remain open as a requested enhancement. I think assigning it to scala_community would be reasonable.

That's fine if the ticket feels slighted, but you're going the wrong way: "closed with needinfo status" means "I will work on this if I am supplied with info" whereas "open and assigned to scala_community" means "nobody is likely to work on this."

@scabug
Copy link
Author

scabug commented Nov 1, 2010

@paulp said:
(In r23427) Created @Strictfp annotation in scala.annotation. If you prefer
your fp with no tolerance for tomfoolery, this is the commit for you.
Closes #1708, review by community.

@scabug
Copy link
Author

scabug commented Nov 1, 2010

@SethTisue said:
awesome. I won't have time to look at this until early December, but I'll definitely look then. (I'm putting it my calendar.)

@scabug
Copy link
Author

scabug commented Jan 20, 2011

@SethTisue said:
I tried this out, using javap to verify the results, and it seems to be working great. thanks so much.

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

No branches or pull requests

1 participant