View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Rounding Numbers.

On Jul 31, 7:12*pm, Max wrote:
In B1: =100*ROUND(A1,2)


Although that is sufficient for the OP's example, it is not always the
case. So in general, I would do ROUND(100*ROUND(A1,2),0) if the
intention is get exactly the same internal representation as we would
get if we entered the integral constant.

Consider the case where A1 is the constant 2.00666666666667.
100*ROUND(A1,2) in B1 seems to result in 201; in fact, (B1 = 201)
results in TRUE. But (B1-200 = 1) results in FALSE.

Of course, the reason is that although ROUND(A1,2) has the same
internal representation as the constant 2.01, 2.01 cannot be
represented exactly in IEEE floating-point[*]. So when we multiply
by 100, we do not get exactly 201. Then when we subtract 200, the
difference between the result and 1 is large enough that Excel does
not consider them equal.
[*] In contrast, in the OP's example, although 2.42 also cannot be
represented exactly internally, 100*ROUND(A1,2) does result in exactly
the same internal representation as the constant 242.


----- original posting -----

On Jul 31, 7:12 pm, Max wrote:
In B1: =100*ROUND(A1,2)
--
Max
Singaporehttp://savefile.com/projects/236895
Downloads:16,400 Files:356 Subscribers:53
xdemechanik
---



"GEM" wrote:
How can I round a number to two decimals. Not using the increase/decrease
decimals. For example...


I get an answer like this, 2.41666666666667, I know that if you lower the
decimals to two units, the cell will show the answer 2.42, but if I use this
cell in a calculation it will still use 2.41666666666667, and will give me an
incorrect answer.


100 * 2.41666666666667 = 241.6666667
100 * 2.42 = 242- Hide quoted text -


- Show quoted text -