Significant digit computation time

  • Thread starter Thread starter Tone L
  • Start date Start date
  • Tags Tags
    Computation Time
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 1K views
Tone L
Messages
72
Reaction score
7
If I am performing simple arithmetic on numbers that extend 12 decimal places i.g;
12.1234567891011 +11.1234567891011 and this calculation occurs 1000+ times, will calculation i.g;

12.123+11.123 speed up computation time if so how much and how do you arrive at this?
 
Physics news on Phys.org
With modern computers the speed up would be very small to near zero. In your first example, the numbers can be represented by a double and in the second by a float. With a float you manipulating fewer bytes of data and hence it will run faster but only slightly.

In this stackoverflow article it mentions that it's machine dependent as to which runs faster as some machines promote floats to doubles and then do the math as doubles whereas others use a combination of software and hardware to allow the machine to do a double add using a float as the basic data type.

http://stackoverflow.com/questions/4584637/double-or-float-which-is-faster
 
  • Like
Likes   Reactions: Tone L
You have to consider that your computer may not know how to calculate in 32bit floats and may have to convert the float operands to double before calculation. The shorter numbers assuming they are float may calculate slower. If everything is double then there is no time difference on modern hardware.

BoB
 
  • Like
Likes   Reactions: jim mcnamara
Command line user programs like awk (a UNIX tool) have done this type of implicit datatype conversion ("under the covers") for many years.