On Saturday 30 October 2004 04:31 pm, Lloyd Zusman wrote:
| For example, explain to me an algorithm which will "properly" do
| rounding in all of the following cases.  How many decimal places will
| the result have, and will there or will there not be any rounding?

You first will have to specify the problem set better then that. For example 
by 2 & 3 I take it you are making a distinction between integers and floats, 
or are we just dealing with reals here and indifferent? If the former do you 
wish the to coerce ints to floats or throw an error? Also what rounding? 
--You didn't specify any percession, or what kind of draw option to use. 
OTOH, maybe you believe these have to be rounded as is for the computer to 
store the result. That's not so. I can represent the results of all these 
calculations without rounding very easily.

| 1.  100 * 9.95
|
| 2.  100 * (29.85 / 3)
|
| 3.  (100 * 29.850) / 3.0
|
| 6.  1 / 3
|
| 7.  1 / 3.0
|
| 8.  1 / sqrt(9)
|
| etc. etc.
|
| What is the intention of the programmer in each case, and what _should_
| the answer be (in terms of number of decimal places, rounding behavior,
| truncation behavior, etc.).

Did you read the alt thread? I'm not talking about variant viable behaviors, 
depending on what one wants. I'm talking about what one should be able to 
expect but doesn't get. I'll distill it for you, try:

  (134.45 / (0.1)).round
  (134.45 * (1.0/0.1)).round

T.