Solved

Floating point calculations varying between computers.

Posted on 2003-11-10
4
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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