close

Read Chip Pearson's article about floating point math

www.cpearson.com/excel/rounding.htmquot;trucatquot; wrote:

gt; I have several errors that occurs in both excel 2000 and excel 2003
gt;
gt; the foundation
gt; . cells from b2 to g2 are formatted in green and with 2 digit number
gt; formats with neg numbers in brackets. H2 is formatted in yellow and contains
gt; the formula, and also the same number format.
gt;
gt; problem #1.
gt; in cell f2 for example, I will put in a number 150.00, then in cell
gt; f3 the new number is 150.01. I then will highlight the two numbers and drag
gt; down to say 148.00. The program will properly sequence the numbers up (or
gt; down for that matter) in the two digit readout format properly. What really
gt; takes the cake is in the formula box. The numbers are not consistantly in
gt; whole integers. Sometimes I have whole integers, but on the whole I am
gt; getting numbers that has anywhere from 9 to 12 zeros after with a 2 or a 7
gt; attached to the end. eg. will be to see this number 150.00
gt; 151.0100000000002 151.020000000000002 and some attach a lot of 9's after.
gt; Now when I highlight two cells of 149.00 and drag down the intergers are in
gt; two decimal places .
gt;
gt; Problem #2
gt; I am doing a simple checkbook style program with two negative
gt; entry columns for business , one column for being paid the day of service.
gt; The second column for any transaction after that date, similar to accounts
gt; receivables.. My twist on this was a math checker in the last column to
gt; check our math, if the numbers are correct it will say quot;matchquot;.
gt; The formula! In cell H2 enter
gt; =if(g2 c2-d2-e2=f2,quot;matchquot;,g2 c2-d2-f2).
gt;
gt; So, I enter the number 149.00 in cell e2, then 0 in f2, and 149 in g2 I get
gt; quot;matchquot;. So, far so good. Now, I put in 149.00in e3, and .01 in f3 and
gt; 149.01 in g3 and I get a red (0.00). the next penny up will give me a
gt; black (0.00)., and so on but some numbers for example such as 2.12, will give
gt; me a quot;matchquot; . I found that retyping the numbers that have long decimal
gt; places such as 151.580000000002 to 151.58 will give me a (0.00). and
gt; 151.590000000002 into 151.59 will return quot;matchquot;.

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()