Solved

Floating point calculations varying between computers.

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 249
System restore point 4 77
Delphi application Soap connection 5 79
Find and Replace Stream with 0s 8 45
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now