On Sat, 2008-05-03 at 15:31 -0700, William Scott Jordan wrote:
> Hey all!
> 
> This is really more of a tcl question, but I'm hoping that someone on 
> the list might have an explanation.  Why does [format %.2f 18.005] round 
> down to "18.00" and [format %.2f 1.415] round up to "1.42"?  Any 
> guesses?  Am I missing something obvious here?
> 

Hello William,

As far as I can see, it's just doing the correct math.

By convention, when you round:

1.00 = 1.0
1.01 = 1.0
1.02 = 1.0
1.03 = 1.0
1.04 = 1.0
1.05 = 1.1
1.06 = 1.1
1.07 = 1.1
1.08 = 1.1
1.09 = 1.1

and so on. This way you get .0 for 5 numbers, .1 for the other numbers,
and then the distribution is uniform. And that's not tcl-only , but they
way they teached me to round numbers in school ;-P

If you simply want to discard the decimal numbers... you'd try a method
different than format's :-)

Regards,

  Juan José


-  
Juan José del Río    |  Comercio online / e-commerce
(+34) 616 512 340    |  [EMAIL PROTECTED]


Simple Option S.L.
  Tel: (+34) 951 930 122
  Fax: (+34) 951 930 122
  http://www.simpleoption.com


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to