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

Home » Public Forums » archive » Re: Floating-point accuracy problem
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: Floating-point accuracy problem [message #72108] Mon, 09 August 2010 09:09
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 8/9/10 9:30 AM, Ramy wrote:
> I have a problem related to float-point accuracy
> If I type in: 50d - 1d-9, I get 50.000000
>
> And here lies my problem, I'm doing a numerical simulation where such
> an arithmetic is common place, and as a result i get a lot or errors.
>
> I know for example, that if i simply type
> print, 50d - 1d-9, format = '(f.20.10)' , i'll get:
> 49.9999999990
>
> But how can I convince IDL to do it on its own during computations?
>
> Any suggestions will be massively welcomed!

You are confusing the computations with the printed output. IDL will do
double precision arithmetic if one of the arguments is a double. When
you print it out, you can choose the format you want to print it out in:

IDL> d = 50d - 1d-9
IDL> print, d
50.000000
IDL> print, d, format='(F20.10)'
49.9999999990

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Floating-point accuracy problem
Next Topic: Re: IDL_Container and garbage collection

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

Current Time: Wed Oct 08 11:40:21 PDT 2025

Total time taken to generate the page: 0.00407 seconds