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

Home » Public Forums » archive » Re: Numbers from nowhere?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Numbers from nowhere? [message #58725] Sun, 17 February 2008 13:53 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
elwood writes:

> But my question is more pointed:
> if you assign x=3.3
> and you know apriori that the floating point data type
> will not have enough bits to store this number precisely,
> why does "print" show this number as 3.3?
>
> Is it because it is rounding off with some kind of algorithm?
> Or am I misinterpreting how this number is being stored?

I presume it is because whatever number *is* stored,
when rounded to the 7-8 significant figures a float
can accurately represent, comes out to 3.300000.

IDL> x=3.3
IDL> print, x, format='(f0)'
3.300000

IDL> print, x, format='(f12.10)'
3.2999999523

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Labeling the x-axis with a non standard time string
Next Topic: idl format codes and output files

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

Current Time: Wed Oct 08 19:25:10 PDT 2025

Total time taken to generate the page: 0.00428 seconds