Vladimir Gazbarov
Vladimir Gazbarov

Reputation: 860

Java - does double and float percision depend on the machine?

I am wondering whether or not Java uses a uniform precision for floating point numbers (float and double), regardless of the machine architecture that runs the VM. This is required because I trying to synchronize some simulations that involve math on several machines and I must make sure that all of the calculations will produce the same results on all of them.

Upvotes: 3

Views: 995

Answers (2)

progrenhard
progrenhard

Reputation: 2363

Java has IEEE 754 single and double precision types.

In other words yes. It will be uniform through out all machines.

However, calculations might vary. @ user2246674

Upvotes: 2

Dawood ibn Kareem
Dawood ibn Kareem

Reputation: 79877

You'll be fine. The precision is specified by the language. It's supposed to be the same on every Java platform. The details are at http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3

Upvotes: 6

Related Questions