Solved

Floating point calculations varying between computers.

Posted on 2003-11-10
4
174 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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