java - what are the uses of by making strictfp class or method? -
marking class strictfp means method code in class conform ieee 754 standard rules floating points.
what means? don't it.
some processors have capabilities more accurate arithmetic - e.g. 80 bits instead of 64 bits. likewise on processors may faster use double
arithmetic logically float
arithmetic used. example:
float foo(float x, float y) { x = x * 1.2345f; y = y * 2.3456f; return x * y; }
here intermediate operations potentially optimized use 80-bit arithmetic throughout, falling 32-bit value when it's returned... though operation described in source code each multiplication theoretically 32-bit multiplication.
when use strictfp
, turn off potential optimizations. it's necessary, means you're guaranteed exact same set of arithmetic operations - when given exact same set of inputs - give exact same set of results regardless of implementation.
Comments
Post a Comment