Re: mathematics-accuracy [message #51378] |
Wed, 15 November 2006 13:43 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
creon writes:
> Hello. I've been having a problem on math operations with floating
> point numbers. I'll be thankful if you help me out with this.
> Now, I have a series of floating-point numbers - str={arr:findgen(x)},
> codes.... the first element of the series is 1.20740. i need to get the
> square of this, which is 1.45781. when i type
> print, str.arr[0]^2
> it returns 1.45780. i tried setting the data types to double - with
> dindgen-, and had 1.45783. I don't know what the problem is, and how i
> can fix it. please help. thanks.
I think you can fix most of your problems by reading this
article, especially the section in the middle about how
PRINT works:
http://www.dfanning.com/math_tips/sky_is_falling.html
Cheers,
David
P.S. Hint, use the FORMAT keyword.
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|