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

Home » Public Forums » archive » Puzzle with floating point underflow
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: Puzzle with floating point underflow [message #26474 is a reply to message #26334] Thu, 23 August 2001 08:21 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Martin Schultz <martin.schultz@dkrz.de> writes:
...
> How can a float number be something e-42 if the system says it can only
> represent numbers down to 1.e-38 in a float????????
>
> test= 8.1047657d-42
> IDL> tmp=float(test)
> % Program caused arithmetic error: Floating underflow
> % Detected at MGS_RGRID::REGRID 203 /pf/m/m218003/home/IDL/lib/mgs_newobjects
> /mgs_rgrid__define.pro
> IDL> help,tmp
> TMP FLOAT = 8.10511e-42

You have a denormalized number! Internally most floating point
numbers are normalized, which means that the mantissa and exponent are
adjusted so that the leading digit in the mantissa is unity. In a
denormalized quantity the mantissa doesn't have that property.

It's better to make an example, in decimal arithmetic. We all know
that we can change this value:

0.02500 x 10^{-38} Denormalized
Mantissa Exponent

into this value

2.50000 x 10^{-40} Normalized
Mantissa Exponent

That is a good way to do it with floating point numbers since there
are a fixed number of bits that can be used to represent the mantissa.
Normalizing maximizes the number of precision bits available for a
given computation.

But what happens when we also only have a fixed number of bits to
represent the *exponent*? Then it may not be possible to represent
10^{-40} since the smallest is 10^{-38}. In that case one has to be
content with the denormalized quantity, like 0.025 x 10^{-38} above.

You don't get something for nothing, though. The trade-off is that
you start to lose precision in the mantissa. The worst case happens
when you have the number 2.5 x 10^{-38} / 10^5, something like this:

0.00002 x 10^{-38} Normalized
Mantissa Exponent

The "5" in 2.5 just got lost! Because the number of available bits of
precision varies with the magnitude of the number, it is best to avoid
these kinds of situations. :-)

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fortran + IDL
Next Topic: Reading a very large ascii data file

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

Current Time: Sun Oct 12 04:58:13 PDT 2025

Total time taken to generate the page: 0.24670 seconds