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

Home » Public Forums » archive » Re: WRONG RESULTS WITH IDL
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: WRONG RESULTS WITH IDL [message #11710 is a reply to message #11708] Tue, 05 May 1998 00:00 Go to previous messageGo to previous message
Thomas A. McGlynn is currently offline  Thomas A. McGlynn
Messages: 23
Registered: March 1996
Junior Member
Frank Loewenthal wrote:
>
> Hi Folks
>
> For calculation of beam-propagation I use IDL. But now I realize that
> for large arguments, even with double-precision, IDL gives wrong
> results:
> For example:
>
> sin(12345678901.12345678901) = -03727 9004 9960 8007
>
> where IDL get:
>
> IDL> x = double(12345678901.12345678901)
> IDL> print, sin(x)
> 0.098761418
>
> Can somebody confirm this result, and does anybody know the solution
> to overcome this problem?
>
> Best regards
>
> Frank

You're misunderstanding how to create a double precision literal in
IDL. E.g.:

IDL> x=12345678901.12345678901
IDL> print,sin(x)
0.0987614
IDL> x=12345678901.12345678901d0
IDL> print,sin(x)
-0.37327885

In the first case the literal value is interpreted in single
precision and then assigned to x. To preserve
the precision you need to indicate that it's a double
precision value.

Regards,
Tom McGlynn
tam@silk.gsfc.nasa.gov
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Q] if-else statement
Next Topic: 5.0 XMANAGER problem

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

Current Time: Sat Nov 29 04:48:27 PST 2025

Total time taken to generate the page: 0.96551 seconds