Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  which FP Math library do you use and recommend?  (Read 5130 times)
0 Members and 1 Guest are viewing this topic.
Offline Mordan

Junior Devvie

« Posted 2011-06-16 13:42:59 »


I have found

Do you have any other?

I need to be 100% certain that two hosts compute the exact same value. using the ACOS function and COS function.

Offline Roquen

JGO Kernel

Medals: 518

« Reply #1 - Posted 2011-06-16 14:07:49 »

The StrictMath versions "should" produce bit identical results on all platforms.  The real trick is that you also have to insure that the inputs are the same on all machines.  Bit-exact floating point is a nasty can of worms.
Offline ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #2 - Posted 2011-06-17 01:21:14 »

java.lang.Math uses java.lang.StrictMath Wink

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #3 - Posted 2011-06-17 04:33:23 »

If you don't want super high accuracy, just portability, then use strictfp in your class definition:

Offline Roquen

JGO Kernel

Medals: 518

« Reply #4 - Posted 2011-06-17 05:26:07 »

java.lang.Math uses java.lang.StrictMath Wink

Only by default.  The JVM patches out the calls to hardware when available.  Using strictfp and StrictMath should insure bit portability, but my confidence level of the JVM and compiler being bug-free in all versions isn't high.
Offline delt0r

JGO Wizard

Medals: 145
Exp: 18 years

Computers can do that?

« Reply #5 - Posted 2011-06-21 14:16:52 »

My understanding is that strict fp means as per IEEE definitions and per the Math javadoc, which IIRC just means 2ulp or better (units in last position) for higher functions. That is the last bit or so *can* be different for things like cos/sin/log/pow/exp etc on different machines/jvm's and still be complaint.

When i need perfect bit accuracy i use Fixed point (ie ints/longs with a POT divisor) or just plan ints.

I have no special talents. I am only passionately curious.--Albert Einstein
Offline Roquen

JGO Kernel

Medals: 518

« Reply #6 - Posted 2011-06-27 11:35:24 »

With strictfp: loads, stores, add, sub, mul & div are all required to be IEEE a given code sequence of these are required to be bit-exact for all archs.  StrictMath is required to be bit-exact (to some version of fdlibm).  So in combo, you should get bit exact results (again assuming no JVM bugs or compiler bugs).  Not that I'd suggest doing this.  Assuming that your computation chains aren't crazy you could just perform the calcualtions in doubles and convert to floats for values that need to be identical.
Pages: [1]
  ignore  |  Print  

hadezbladez (292 views)
2018-11-16 13:46:03

hadezbladez (162 views)
2018-11-16 13:41:33

hadezbladez (293 views)
2018-11-16 13:35:35

hadezbladez (73 views)
2018-11-16 13:32:03

EgonOlsen (2154 views)
2018-06-10 19:43:48

EgonOlsen (2181 views)
2018-06-10 19:43:44

EgonOlsen (1368 views)
2018-06-10 19:43:20

DesertCoockie (1985 views)
2018-05-13 18:23:11

nelsongames (1628 views)
2018-04-24 18:15:36

nelsongames (2275 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!