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

Home » Public Forums » archive » Program caused arithmetic error: Floating underflow
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
Program caused arithmetic error: Floating underflow [message #88771] Wed, 18 June 2014 02:37 Go to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Hi

I have the following expression:

value = 0

for i=0, 283 do begin
for j=0, 283 do begin
value = (value + (A[i,j]-B[i,j])^2.)/17000.
endfor
endfor

when I type, print value I got the following error:
% Program caused arithmetic error: Floating underflow

Does anyone know why this happens?

Regards,
Gina
Re: Program caused arithmetic error: Floating underflow [message #88772 is a reply to message #88771] Wed, 18 June 2014 02:52 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
Hi,

On 18.06.2014 11:37, g.nacarts@gmail.com wrote:
> % Program caused arithmetic error: Floating underflow

typing the exact same error message in search engines gives very helpful
and pertinent links, the first result in g**g** being:

http://www.idlcoyote.com/math_tips/underflow.html

Cheers,

Fabien
Re: Program caused arithmetic error: Floating underflow [message #88773 is a reply to message #88771] Wed, 18 June 2014 03:10 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Thanks for your response. Actually I already had a look on this link but I couldn't manage to solve my problem. I used the L to make it LONG but I didn't see any number in the outputs.
Re: Program caused arithmetic error: Floating underflow [message #88775 is a reply to message #88773] Wed, 18 June 2014 04:37 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
On 18.06.2014 12:10, g.nacarts@gmail.com wrote:
> I couldn't manage to solve my problem.

Well it's mostly not a problem and could be ignored. It depends on your
numbers A and B:

IDL> print, 1e-30 / 17000
5.88235e-35
IDL> print, 1e-50 / 17000
0.00000
% Program caused arithmetic error: Floating underflow
Re: Program caused arithmetic error: Floating underflow [message #88776 is a reply to message #88771] Wed, 18 June 2014 04:40 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Note that in the last iteration, your result will essentially be divided by ((17000^283)^283).
Re: Program caused arithmetic error: Floating underflow [message #88777 is a reply to message #88771] Wed, 18 June 2014 05:11 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Well, I can't ignore it because I need the values of the parameter "value" as shown in the expression. But since this cause an overflow I didn't get any result. There is any way to overcome this issue?
Re: Program caused arithmetic error: Floating underflow [message #88778 is a reply to message #88777] Wed, 18 June 2014 05:28 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
I don't think that normal computers are made to represent the number
((17000^283)^283) as Matthew pointed out. Maybe you need to explain why
you want to divide your value by the size of the universe ... twice.
Re: Program caused arithmetic error: Floating underflow [message #88779 is a reply to message #88777] Wed, 18 June 2014 05:59 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
... if you sure that the formulation of your loop is correct you could
try using double precision numbers. This will just allow value to become
even closer to 0 than it was already:

IDL> print, 1e-50 / 17000
0.00000
% Program caused arithmetic error: Floating underflow
IDL> print, 1d-50 / 17000d
5.8823529e-55
Re: Program caused arithmetic error: Floating underflow [message #88780 is a reply to message #88771] Wed, 18 June 2014 08:38 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Why the last iteration will be divided by (17000^283)^283? I thought that for each iteration the value be divided by 17000.
Re: Program caused arithmetic error: Floating underflow [message #88781 is a reply to message #88780] Wed, 18 June 2014 09:05 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 18:e juni 2014 kl. 17:38:45 UTC+2 skrev g.na...@gmail.com:
> Why the last iteration will be divided by (17000^283)^283? I thought that for each iteration the value be divided by 17000.

The value from the first iteration will be divided by that number. The contribution from each iteration will be divided by one factor 17000 less than the previous one. The value from the last iteration will be divided by 17000 only.
Re: Program caused arithmetic error: Floating underflow [message #88782 is a reply to message #88780] Wed, 18 June 2014 09:10 Go to previous message
Chip Helms is currently offline  Chip Helms
Messages: 24
Registered: November 2012
Junior Member
On Wednesday, June 18, 2014 3:38:45 PM UTC, g.na...@gmail.com wrote:
> Why the last iteration will be divided by (17000^283)^283? I thought that for each iteration the value be divided by 17000.

If you still find yourself having issues locating the problem, you might double check that the issue isn't occurring somewhere else nearby in the code (I believe the default behavior is for IDL to issue math error warnings only when it returns to interactive prompt). If you set !EXCEPT=2, IDL will issue warnings (complete with line numbers) at the time the error occurs.

http://www.exelisvis.com/docs/error_handling_system_va.html# sysvars_272074529_1002623

Also, currently, your code is dividing the current running total by 17000 at each step (so the division occurs 284*284 or 80656 times, granted it's not the same as finding the total and dividing by 17000d^80656). I'm guessing this is to converge on the parameter value iteratively?

Cheers,
Chip
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: converting strings to float
Next Topic: map_set without any grid lines

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

Current Time: Wed Oct 08 12:29:13 PDT 2025

Total time taken to generate the page: 0.00563 seconds