Re: Can someone please explain - real numbers
- From: Paul W <noemail@xxxxxxxxx>
- Date: Wed, 08 Nov 2006 06:45:45 +0000
On Wed, 08 Nov 2006 19:35:09 +1300, Nicholas Sherlock
<N.sherlock@xxxxxxxxx> wrote:
Paul W wrote:
Thanks for all the replies.
Clearly I know nothing about how a computer stores "real" numbers.
Even after all this time!
It just amazes me that telling a computer to store a value of 2.21
(effectively 2.210000000 recurring) it decides to store a value like
2.211189899324 (or whatever). I thought the whole point of computers
is they were accurate for this sort of thing.
So I can use extended (is that spot on then?), but then what on earth
is the point of "real" numbers if they're not accurate?
The reason that you cannot get an exact representation of decimal
numbers as a floating point type is that some decimal numbers require an
infinite amount of binary digits to represent. It's the same way that
1/3 is 0.333333 (and so on) in decimal - there is no exact way to
represent the number in decimal. Since we don't want to use an infinite
amount of storage space to hold our numbers, we must store a certain
number of binary digits and throw away the rest. This is why you don't
get exactly 2.21 stored in your floating point value, no matter what
precision you choose. Higher precision values are more accurate, but
some numbers simply cannot be exactly represented in floating point.
(I was useless at maths, unsurprisingly).
I always thought a computer would store something like 1/3
(0.33333...) simply as 0.33333... for as many decimal places it could
and then stopped. Is that not the case then?
So equally 2.1 would simply be stored 2.100000... again for as many
digits as that particular number "type" allowed.
I recommend:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
If you are interested in learning more. They can explain it much better
than I can.
Thanks I'll have a read through it, although it looks like a nightmare
to me!
.
- Follow-Ups:
- Re: Can someone please explain - real numbers
- From: John Dough
- Re: Can someone please explain - real numbers
- From: alanglloyd@xxxxxxx
- Re: Can someone please explain - real numbers
- From: Rob Kennedy
- Re: Can someone please explain - real numbers
- References:
- Can someone please explain - real numbers
- From: Paul W
- Re: Can someone please explain - real numbers
- From: Paul W
- Re: Can someone please explain - real numbers
- From: Nicholas Sherlock
- Can someone please explain - real numbers
- Prev by Date: Re: Can someone please explain - real numbers
- Next by Date: Re: Can someone please explain - real numbers
- Previous by thread: Re: Can someone please explain - real numbers
- Next by thread: Re: Can someone please explain - real numbers
- Index(es):
Relevant Pages
|