floating point - strictfp in Java -
i'm implementing neural network library in java , , there intensive double
(not double
) matrix operations, matrices large , performance required of course.
so came read strictfp
keyword didn't understand , looking simple explanation if should using or not , why
strictfp indicates floating point calculations should use exact ieee754 standard. without strictfp, vm free use other (but platform dependent) representations of intermediate float , double values, in order increase precision.
use strictfp if need exact same results on multiple platforms. avoid if want best precision current platform can give you.
e.g. in following simple addition:
2.0 + 1.1 + 3.0
do want intermediate results (e.g. 2.0 + 1.1) represented ieee754 standard double, or best possible precision platform allows. strictfp ensures first, not using strictfp allows vm use second alternative.
not using strictfp not hurt performance, , may on platforms native float types don't map ieee754 increase performance, since vm isn't required convert , forth in between native , ieee754 formats. answer platform dependent, you'll need measure.
Comments
Post a Comment