comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Why does 0.8 = 0.80000001 ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Why does 0.8 = 0.80000001 ? [message #31899] Mon, 26 August 2002 06:43 Go to next message
Benjamin Panter is currently offline  Benjamin Panter
Messages: 6
Registered: August 2002
Junior Member
David Fanning wrote:

>
> You will want to read this article:
>
> http://www.dfanning.com/math_tips/sky_is_falling.html
>

Oops - what a numpty!

I had it in my head that it was 12 sig fig with an internal mantissa of 14,
as I mentioned I wasn't overly paniced about it, more interested in finding
out what was going on. Glad to get that cleared up!

Thanks for your help,

Ben
Re: Why does 0.8 = 0.80000001 ? [message #31901 is a reply to message #31899] Mon, 26 August 2002 06:14 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Benjamin Panter (benpanterREMOVE@bigfoot.com) writes:

> I've just found something quite interesting and I wonder if anyone had
> any clues as to why it's happening
>
> I have a rather huge program which spits out a set of numbers in an
> array called str1, declared as a double. When I try to set one of the
> elements to 0.8, it actually sets to 0.80000001... this is below the
> accuracy that I worry about, but I'm just rather interested as to why it
> happens. Some output is below

You will want to read this article:

http://www.dfanning.com/math_tips/sky_is_falling.html

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Why does 0.8 = 0.80000001 ? [message #31955 is a reply to message #31899] Wed, 28 August 2002 17:35 Go to previous message
condor is currently offline  condor
Messages: 35
Registered: January 2002
Member
Benjamin Panter <benpanterREMOVE@bigfoot.com> wrote in message news:<3D6A306A.BF422364@bigfoot.com>...

> I had it in my head that it was 12 sig fig with an internal mantissa of 14,
> as I mentioned I wasn't overly paniced about it, more interested in finding
> out what was going on. Glad to get that cleared up!

It is actually about 15 significant figures:


help,str1
STR1 DOUBLE = Array[17]
str1[6] = 0.8 ; the original example
print,str1[6]
0.80000001
str1[6] = 0.8d0 ; the correct way
print,str1[6]
0.80000000

...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: call_external: passing string from IDL to C
Next Topic: Optimal interpolation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 23:01:19 PDT 2025

Total time taken to generate the page: 0.40166 seconds