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

Home » Public Forums » archive » Re: Floating Array Shows no numbers after the dot
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 Array Shows no numbers after the dot [message #29454] Wed, 20 February 2002 07:09
Martin Downing is currently offline  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 Go to previous message
tam is currently offline  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 Go to previous message
Craig Markwardt is currently offline  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 Go to previous message
Martin Downing is currently offline  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 Go to previous message
David Fanning is currently offline  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
Re: Floating Array Shows no numbers after the dot [message #29466 is a reply to message #29465] Tue, 19 February 2002 09:07 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
"Emmler, Oliver" wrote:
>
> 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 ?
>
> Regards,
> Oliver
>

Dear Oliver,

float has only 6 digits. (6.5 digits)

If you like to have more digits you should use double.
You should then format the output with e.g.

print,array[0],format=('F20.8)'



Reimar


> --
> Oliver Emmler
> University of Heidelberg
> Departement of Radiology
> Phone: +49-6221-7963059 E-Mail: Oliver.Emmler@med.uni-heidelberg.de

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Color problems with 5.5/RH linux 7.1
Next Topic: Creating embedded license .sav files

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

Current Time: Wed Oct 08 11:44:00 PDT 2025

Total time taken to generate the page: 0.00591 seconds