Thread: Decimals, how?
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Decimals, how?

Ron and David wrote:
=ROUND(A19-0.4,0)


For a numerical solution, I would be inclined to do:

=ROUND(ROUND(A19,2)-0.4,0)

to minimize surprises in the general case.

Ron and David's formula might suffice if the OP's numbers are all constants.
And it might suffice even if they are the result of formulas, as long as the
order of magnitude is relatively small.

But consider this contrived example:

A19: =3333.9 - 11*2^-41

That is largest difference (about 5E-12) that displays as 3333.90...0 to 11
decimal places (15 significant digits). We have seen such small numerical
aberrations arising from arithmetic formulas.

ROUND(A19 - 0.4, 0) results in 3333, whereas ROUND(ROUND(A19,2) - 0.4, 0)
results in 3334 as desired.

I was unable to find a simple set of arithmetic operations that results in
the contrived value in A19. But that should not be misconstrued to mean
that there is none. It simply means that I got tired of trying ;).

For example, 113333.9 - 110000 comes very close. It differs from the
contrived value by only 1 bit (the 2nd least significant bit). But
113333.9 - 110000 displays as 3333.89...9 when formatted to 11 decimal
places. So arguably, Ron and David's formula would be sufficient, by
coincidence.

But I think ROUND(ROUND(A19,2) - 0.4, 0) would work better even in this last
example because the OP is likely to display the result with 10 dp or less
(in fact, probably 2 dp), in which case it __appears__ to be 3333.90...0,
and the OP might expect it to round to 3334.


----- original message -----

"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
=ROUND(A19-0.4,0)
--
David Biddulph

LogiMAX wrote:
I need to round up decimals if they are greater than .9 and down
otherwise...

ex..
33.90 should be rounded to 34
33.98 should be rounded to 34
33.20 should be rounded to 33
33.89 should be rounded to 33

How do I make this happen? Thanks in advance...