Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Yes; software arithmetic really is 100 times slower than hardware. Or, at least, it is a a lot slower, and a factor of 100, give or take an order of magnitude, is about right. Back in the bad old days when you could not assume that every 80386 had an 80387 floating-point co-processor, then you had software simulation of binary floating point too, and that was slow.</li> <li>No; you are living in a fantasy land if you think that a pure binary floating point can ever exactly represent all decimal numbers. Binary numbers can combine halves, quarters, eighths, etc, but since an exact decimal of 0.01 requires two factors of one fifth and one factor of one quarter (1/100 = (1/4)*(1/5)*(1/5)) and since one fifth has no exact representation in binary, you cannot exactly represent all decimal values with binary values (because 0.01 is a counter-example which cannot be represented exactly, but is representative of a huge class of decimal numbers that cannot be represented exactly).</li> </ol> <p>So, you have to decide whether you can deal with the rounding before you call ToString() or whether you need to find some other mechanism that will deal with rounding your results as they are converted to a string. Or you can continue to use decimal arithmetic since it will remain accurate, and it will get faster once machines are released that support the new IEEE 754 decimal arithmetic in hardware.</p> <p>Obligatory cross-reference: <a href="http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf" rel="noreferrer">What Every Computer Scientist Should Know About Floating-Point Arithmetic</a>. That's one of many possible URLs and leads to a PDF file. There's an HTML version at <a href="http://docs.sun.com/source/806-3568/ncg_goldberg.html" rel="noreferrer">Sun</a> which is apparently an edited version of the same paper.</p> <p>Information on decimal arithmetic and the new IEEE 754:2008 standard at this <a href="http://speleotrove.com/decimal/" rel="noreferrer">Speleotrove</a> site (material previously hosted at <a href="http://www2.hursley.ibm.com/decimal" rel="noreferrer">IBM</a>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload