Classic RW 2 (was: Rounding errors
From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 09/01/04
- Next message: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Previous message: William M. Klein: "Re: Rounding (COBOL and otherwise)"
- In reply to: Robert Wagner: "Re: Rounding errors"
- Next in thread: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Reply: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Reply: Robert Wagner: "Re: Classic RW 2 (was: Rounding errors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 22:11:12 -0500
Let's look at how changing logic is used in a classic RW response
--
Bill Klein
wmklein <at> ix.netcom.com
"Robert Wagner" <robert@wagner.net.yourmammaharvests> wrote in message
news:052aj0lmkgdi0r22g75jskjrqg8vv4se50@4ax.com...
> On 30 Aug 2004 12:39:58 -0700, riplin@Azonic.co.nz (Richard) wrote:
<snip>
> What if the numbers were not truncated, computed or rounded? I posted
> a demo of that case to which you had no reasonable answer.
>
>>> but it does in Cobol due to a bug.
>>
>>No. Wrong. The rounding mechanism is well defined and works
>>identically in primary school textbooks, mechanical adding machines,
>>C, Java, and Cobol.
>
> You're incorrect. It doesn't work that way in C# nor in JavaScript (I
> don't know about compiled Java).
>
<snip>
The original post stated,
"works identically in primary school textbooks, mechanical adding machines, C,
Java, and Cobol."
The response says that this is INCORRECT because (and I quote)
It doesn't work that way in C# nor in JavaScript (I don't know about compiled
Java)."
So now, tell me why does RW think this response has any relationship to the
original statement?
If the original statement had been,
"works identically in all variations and derrivites of Java and C and COBOL."
then his response would have been responsive.
Only (well that IS an exageration <G>) RW would respond to
"A and B work the same"
with the statement
"Incorrect, A and D don't work the same"
***
Again, (because I think I know what he MEANT to say), it would be nice if he
would respond correctly with a statement like,
"Sorry for my original mis-statement. What I meant to say was
You may (or may not) be right when you said ' rounding mechanism is well
defined and works identically in primary school textbooks, mechanical adding
machines, >>C, Java, and Cobol.'
but it is also true that there are many other programming languages that use
other approaches for rounding that avoid what I think is an unwarrented bias.
For example, C# and JavaScript use "bankers' rounding" see:
For C# :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmathclassroundtopic3.aspFor JavaScript: well, oops, according to at least one reference, JavaScript does NOT use"bankers rounding" for its "normal" rounding. See:http://www.developingskills.com/ds.php?article=jsround&page=1which says,"Math.round - if the decimal part is 0.5 or more, it is rounded up. If it's lessthan 0.5, it is rounded down. This is just the way we're taught at school and isideal unless we specifically need something different."and later says,"Many programming languages use a type of rounding called "round to even" or"banker's rounding". This means that rounding works in the normal way EXCEPTwhen the decimal part is exactly 0.5. In this case it will round to the nearesteven number. So 1.5 rounds to 2 and so does 2.5. The Javascript function toachieve this is: function roundToEven(num){ if ((Math.floor(num)%2==0) && (Math.abs(num-Math.floor(num))==0.5)) return Math.round(num)-1; else return Math.round(num); }"
- Next message: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Previous message: William M. Klein: "Re: Rounding (COBOL and otherwise)"
- In reply to: Robert Wagner: "Re: Rounding errors"
- Next in thread: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Reply: William M. Klein: "Re: Classic RW 2 (was: Rounding errors"
- Reply: Robert Wagner: "Re: Classic RW 2 (was: Rounding errors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|