Re: why Math.Log(8,2) is 2.9999999999999996 and not 3
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 06/22/04
- Next message: Jon Skeet [C# MVP]: "Re: Using new vs virtual and override question"
- Previous message: Jon Skeet [C# MVP]: "Re: Once again Math.Log"
- In reply to: Stu Smith: "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"
- Reply: 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:36:00 +0100
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: Jon Skeet [C# MVP]: "Re: Using new vs virtual and override question"
- Previous message: Jon Skeet [C# MVP]: "Re: Once again Math.Log"
- In reply to: Stu Smith: "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"
- Reply: Colin Young: "Re: why Math.Log(8,2) is 2.9999999999999996 and not 3"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|