Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Significant digit computation time

  1. Sep 16, 2016 #1
    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?
  2. jcsd
  3. Sep 16, 2016 #2


    Staff: Mentor

    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.

  4. Sep 17, 2016 #3


    User Avatar
    Gold Member

    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.

  5. Sep 17, 2016 #4

    jim mcnamara

    User Avatar

    Staff: Mentor

    Command line user programs like awk (a UNIX tool) have done this type of implicit datatype conversion ("under the covers") for many years.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted