"Xu, Weining" wrote:

> May be I didn't say clearly on my question.  Add 0.005 to the number prior
> to the rounding would cause the number always add one to the last decimal,
> such as 2.3237 became 2.33, which is not what I want.  I just need to do
> normal rounding, meaning if 5 and up goes up, 4 and below takes off.

Yes, if you added 0.005 before applying a TRUE ROUNDING to the number,
it would behave as specified, as true rounding is defined as adding (in
this case) 0.005, then truncating (which always rounds down), and you
would effectively be adding 0.005 twice, then truncating. Thus, if the
number is being truncated, and you want true rounding, add the 0.005; if
the number is being truly rounded and you want truncation, you could
subtract 0.005.

As to whether DOUBLE would work better, it might. There are certain
numbers that have an exact decimal representation, but simply cannot be
represented exactly in floating-point binary (just as there are some
numbers, e.g., 1/3, that can be exactly represented as indicated
quotients, but cannot be exactly represented in decimals).

--
James H. H. Lampert
Professional Dilettante
http://www.hb.quik.com/jamesl
http://members.hostedscripts.com/antispam.html
http://www.thehungersite.com

Read My Lips: No More Atrocities!


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.