floating point - Why do doubles work how they do -


i know may common question, have never found answer (and maybe has not knowing how search google correctly, if can point me reference, remove question).

why doubles work how in terms of representing right side of decimal inverse power of 2, , left side of decimal power of 2? know allows large numbers represented, there other advantages? .net framework has decimal data structure available, seems more logical use becuase how represent numbers in human notation.

really, question why doubles created way instead of creating decimal instead (which seems far less common).

your confusion seems unfounded. right side of decimal point always represented in inverse power of base , left side always represented power of base. true base 10 , base 2 well. binary floating point numbers store exponent controls decimal point on mantissa.

as why exist: binary floating point notation has 2 convenient properties:

  1. it relatively fast, because uses binary arithmetic
  2. it can represent either large or small numbers accuracy.

those properties make them pretty e.g. physical calculations, because small error in last place doesn't matter much, make them unusable monetary applications (where want decimal, despite being slower computation).


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -