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

    jedishrfu

    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.

    http://stackoverflow.com/questions/4584637/double-or-float-which-is-faster
     
  4. Sep 17, 2016 #3

    rbelli1

    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.

    BoB
     
  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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Significant digit computation time
  1. New computer time! (Replies: 24)

  2. Digital Networks (Replies: 2)

Loading...