Re: Floating Array Shows no numbers after the dot [message #29454] |
Wed, 20 February 2002 07:09 |
Martin Downing
Messages: 136 Registered: September 1998
|
Senior Member |
|
|
"Craig Markwardt" <craigmnet@cow.physics.wisc.edu> wrote in message
news:onsn7wtejc.fsf@cow.physics.wisc.edu...
>
> "Martin Downing" <martin.downing@ntlworld.com> writes:
>> [hmm - as an aside, does anyone know why DOUBLE can only store 2 more
digits
>> cf. FLOAT considering it uses 4 extra bytes which is enough for a 10
digit
>> LONG ?]
>
> Hi Martin--
>
> Where are you getting your info? I get the following:
> float - mantissa 24 bis = 7.2 decimal digits
> double - mantissa 53 bits = 16.0 decimal digits
> DOUBLE can store more than twice as many digits as FLOAT. The
> increase in digits in the exponent is fewer. I got these values from
> MACHAR().
>
Its Ok, I was just advertising how stupid my brain can be before I have
fully woken up/recaffienated. I was of course observing print default
formats.
I think its called doing a "Homer" (-:0) Doh!
Martin
|
|
|
Re: Floating Array Shows no numbers after the dot [message #29455 is a reply to message #29454] |
Wed, 20 February 2002 06:19  |
tam
Messages: 48 Registered: February 2000
|
Member |
|
|
Martin Downing wrote:
... Explanation of double versus float elided.
> [hmm - as an aside, does anyone know why DOUBLE can only store 2 more digits
> cf. FLOAT considering it uses 4 extra bytes which is enough for a 10 digit
> LONG ?]
>
> Martin
>
Surely an FAQ...
Try
pi = 4*atan(1.0d0)
print, pi
Next do
print, pi, format='(f25.20)'
It is easy to confuse the default display precision with the
internal precision.
Regards,
Tom McGlynn
|
|
|
Re: Floating Array Shows no numbers after the dot [message #29456 is a reply to message #29455] |
Wed, 20 February 2002 06:26  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Martin Downing" <martin.downing@ntlworld.com> writes:
> [hmm - as an aside, does anyone know why DOUBLE can only store 2 more digits
> cf. FLOAT considering it uses 4 extra bytes which is enough for a 10 digit
> LONG ?]
Hi Martin--
Where are you getting your info? I get the following:
float - mantissa 24 bis = 7.2 decimal digits
double - mantissa 53 bits = 16.0 decimal digits
DOUBLE can store more than twice as many digits as FLOAT. The
increase in digits in the exponent is fewer. I got these values from
MACHAR().
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Floating Array Shows no numbers after the dot [message #29457 is a reply to message #29455] |
Wed, 20 February 2002 01:32  |
Martin Downing
Messages: 136 Registered: September 1998
|
Senior Member |
|
|
"Emmler, Oliver" <oemmler@ix.urz.uni-heidelberg.de> wrote in message
news:a4tre2$lgv$1@news.urz.uni-heidelberg.de...
> Hi,
>
> I tried the following:
>
> Array = FLTARR[15]
> Time = 123456.123456
> Array[0] = Time
> Print, Array[0]
>
> All numbers after the colon are gone.
>
> Can anyone help ?
> Do i have to use DCOMPLEXARR ?
> Is this problem caused by Pre-Formatting due to the system ?
>
Hi Oliver,
The answer is simple - the FLOAT type which you are using has only 6
significant digits, whereas type DOUBLE has a couple more, and COMPLEX is
for complex numbers :)
[hmm - as an aside, does anyone know why DOUBLE can only store 2 more digits
cf. FLOAT considering it uses 4 extra bytes which is enough for a 10 digit
LONG ?]
Martin
|
|
|
Re: Floating Array Shows no numbers after the dot [message #29465 is a reply to message #29457] |
Tue, 19 February 2002 09:26  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Emmler, Oliver (oemmler@ix.urz.uni-heidelberg.de) writes:
> I tried the following:
>
> Array = FLTARR[15]
> Time = 123456.123456
> Array[0] = Time
> Print, Array[0]
>
> All numbers after the colon are gone.
>
> Can anyone help ?
> Do i have to use DCOMPLEXARR ?
> Is this problem caused by Pre-Formatting due to the system ?
You are running into default formatting problems, for sure.
Try this:
Print, array[0], Format='(F13.6)'
And if you really need all those decimal points, you are
probably going to have to make this a double precision array
(DBLARR). Double complex is probably going a bit overboard,
however. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
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
|
|
|
|