Solved

Floating point calculations varying between computers.

Posted on 2003-11-10
4
175 Views
Last Modified: 2010-04-05
I am building an application where two instances, running on two seperate machines, must make the same floating point calculations given the same inputs.

I know that there can be problems with double values.  The two computers will not always make the same calculation due to differrences in precision settings in the FPU.  FPU settings can be changed at any time by other programs that are running concurrently.

Does the same apply to single values? or, are single values at a low enough precision, that even the lowest precision FPU settings will not affect the consistency of calculations on seperate computers?

I am looking for a simple Yes or NO answer with a good explanation of why.

Thank you.

0
Comment
Question by:wolsen
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Vihmapuu
ID: 9826423
There is no difference in double or single values except that they have different precision.
Would there be a way of avoiding floating point calculations?
For example, you could use int64 and then divide it by 10000 to get your 4 digits only when showing to the user.
0
 
LVL 2

Author Comment

by:wolsen
ID: 9826912
The difference in precision is the crucial factor.  My hunch is that a lower precision type may not be affected by differing FPU settings.

I will restate my question differrently:

Are single value calculations affected by the FPU precision settings, or will they always be the same?  I know for certain that double value calculations are not consistent between computers.  I have done tests to confirm this.  I have since changed to using single values, and I have not seen the inconsistency happening, but I want to make sure that it will never happen with single values.

I am only using basic operations (+,-,*,/) in the calculations.

Will single values always have the same results between differrent computers when the above operations used.  Yes or No?  Why?
0
 
LVL 1

Accepted Solution

by:
Vihmapuu earned 100 total points
ID: 9830291
I can't answer that.
I would just use int64 (that is more precise and faster, too) and forget about single values. Unless if you are only interested in science and not a practical approach.
Integers are guaranteed to give you the same result with any machine and any conditions.
0
 
LVL 2

Author Comment

by:wolsen
ID: 12288530
I changed to using single values and the problem went away.  The calculations only varied when using double values.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question