Re: why Math.Log(8,2) is 2.9999999999999996 and not 3
From: Colin Young (x_at_nospam.com)
Date: 06/22/04
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: A problem on GC"
- Previous message: hazz: "Re: threading and Principal question - from Role-based security to declarative security."
- In reply to: Jon Skeet [C# MVP]: "Re: why Math.Log(8,2) is 2.9999999999999996 and not 3"
- Next in thread: Colin Young: "Re: why Math.Log(8,2) is 2.9999999999999996 and not 3"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Jun 2004 11:11:13 -0400
Here's a decent article explaining numbers in computers in pretty simple
terms: http://www.sybase.com/detail?id=1012599. I'm including it for
completeness for interested observers, not that I think Mr. Smith or Mr.
Skeet need this explained to them (I have a naive hope that people having
trouble with floating point will do a google search first and find this
thread archived).
I've actually never really completely understood the whole decimal thing. I
blame it on my engineering education. As far as I'm concerned 1.24e4 +
9.3e-1 = 1.24e4, but just try telling an accountant that 93 cents can just
be ignored.
Colin
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1b421be616c5d79098ad36@msnews.microsoft.com...
> Stu Smith <stuarts@nospam-digita.com> wrote:
> > Apologies, it was smart-ass-ness. It was just that chap said you "CAN'T"
get
> > exact results from floating point, which to me seems just as inaccurate
as
> > expecting exact results every time. Some numbers can be represented
exactly,
> > and some (most!) numbers can't be. Obviously all FP numbers are exact
> > numbers themselves; it's the FP operations which give mathematically
inexact
> > results at certain (but not all) times.
>
> How you regard FP numbers is an interesting point, actually. You can
> either regard them as exact numbers which are within a certain distance
> of the last calculation, or you can regard them as a range in and of
> themselves. I've never been entirely certain which is the best way of
> thinking of them - I suspect it depends on the situation.
>
> My point about decimal vs double is an important one though - people
> tend to think of decimals as "exact" and doubles as "rough" when
> there's no such distinction in reality - they have different bases,
> levels of precision and scale ranges, but they're fundamentally much
> more similar than they're usually portrayed.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: A problem on GC"
- Previous message: hazz: "Re: threading and Principal question - from Role-based security to declarative security."
- In reply to: Jon Skeet [C# MVP]: "Re: why Math.Log(8,2) is 2.9999999999999996 and not 3"
- Next in thread: Colin Young: "Re: why Math.Log(8,2) is 2.9999999999999996 and not 3"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|