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

Home » Public Forums » archive » Re: what is Floating illegal operand question?
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: what is Floating illegal operand question? [message #43676] Tue, 19 April 2005 04:51
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Mike and James,
Thanks for the clarification. I was thrown off by the emphasized on floating
numbers on the mathworld web site. Deep inside it did not make any sense, so
I blamed it on the lecture I mussed have missed in college. :-)
Mike's explanation makes perfect sense, so thanks for straightening me
out...

Cheers,
Haje



"Michael Wallace" <mwallace.no.spam@no.spam.swri.edu.invalid> wrote in
message news:1168aupboi2v87b@corp.supernews.com...
> (0 / 0) is just as undefined as (0.0 / 0.0) is. However, there is no way
> to express NaN or Infinity when working with integers. The IEEE floating
> point specification allows for NaN and Infinity, but the integer spec does
> not. Without a NaN option, IDL (and other languages as well), default to
> evaluating (0 / 0) as 0 even though this is technically incorrect.
>
> -Mike
>
>
> Haje Korth wrote:
>> Well, if I understand this right, 0/0 is defined and the result is 0, so
>> that the division by zero message is only informational. On the other
>> hand 0./0. is not defined for floating point numbers and results in an
>> error (see http://mathworld.wolfram.com/DivisionbyZero.html). Correct me
>> if I am wrong.
>>
>> Haje
>>
>>
>>> You're getting it from a floating point divide by zero. When using
>>> integers, IDL actually tells you that you tried to divide by zero. For
>>> some reason, they have a different message for floating point.
>>>
>>> IDL> x = 0 / 0
>>> % Program caused arithmetic error: Integer divide by 0
>>> IDL> x = 0.0 / 0.0
>>> % Program caused arithmetic error: Floating illegal operand
>>>
>>> -Mike
>>
>>
Re: what is Floating illegal operand question? [message #43679 is a reply to message #43676] Tue, 19 April 2005 03:03 Go to previous message
peter.julyan is currently offline  peter.julyan
Messages: 3
Registered: June 2004
Junior Member
This used to really bug me then I discovered that the manual says "In
the vast majority of cases, floating-point underflow errors are
harmless and can be ignored", and that they can be suppressed by
setting:

!EXCEPT=0

If you dare...

Pete.
Re: what is Floating illegal operand question? [message #43681 is a reply to message #43679] Tue, 19 April 2005 01:43 Go to previous message
m_schellens is currently offline  m_schellens
Messages: 31
Registered: February 2005
Member
Note that in IDL *any* integer devided by 0 evaluates as divided by 1.
marc
Re: what is Floating illegal operand question? [message #43687 is a reply to message #43681] Mon, 18 April 2005 16:08 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
thanks a lot
Re: what is Floating illegal operand question? [message #43689 is a reply to message #43687] Mon, 18 April 2005 14:51 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
(0 / 0) is just as undefined as (0.0 / 0.0) is. However, there is no
way to express NaN or Infinity when working with integers. The IEEE
floating point specification allows for NaN and Infinity, but the
integer spec does not. Without a NaN option, IDL (and other languages
as well), default to evaluating (0 / 0) as 0 even though this is
technically incorrect.

-Mike


Haje Korth wrote:
> Well, if I understand this right, 0/0 is defined and the result is 0, so
> that the division by zero message is only informational. On the other hand
> 0./0. is not defined for floating point numbers and results in an error (see
> http://mathworld.wolfram.com/DivisionbyZero.html). Correct me if I am wrong.
>
> Haje
>
>
>> You're getting it from a floating point divide by zero. When using
>> integers, IDL actually tells you that you tried to divide by zero. For
>> some reason, they have a different message for floating point.
>>
>> IDL> x = 0 / 0
>> % Program caused arithmetic error: Integer divide by 0
>> IDL> x = 0.0 / 0.0
>> % Program caused arithmetic error: Floating illegal operand
>>
>> -Mike
>
>
>
Re: what is Floating illegal operand question? [message #43690 is a reply to message #43689] Mon, 18 April 2005 14:24 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Haje Korth wrote:
> Well, if I understand this right, 0/0 is defined and the result is 0, so
> that the division by zero message is only informational. On the other hand
> 0./0. is not defined for floating point numbers and results in an error (see
> http://mathworld.wolfram.com/DivisionbyZero.html). Correct me if I am wrong.

0/0 is exactly as undefined for integers as 0.0/0.0 is for floating
point. To see why that is true, please try to identify a finite floating
point value for f that is NOT a solution to this equation:

0.0*f eq 0.0

Then try to find an integer value for i that is NOT a solution for

0*i eq 0

Is it any easier for the integer case than for the floating point case?
Re: what is Floating illegal operand question? [message #43691 is a reply to message #43690] Mon, 18 April 2005 14:02 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Well, if I understand this right, 0/0 is defined and the result is 0, so
that the division by zero message is only informational. On the other hand
0./0. is not defined for floating point numbers and results in an error (see
http://mathworld.wolfram.com/DivisionbyZero.html). Correct me if I am wrong.

Haje



"Michael Wallace" <mwallace.no.spam@no.spam.swri.edu.invalid> wrote in
message news:11687a01efaaa29@corp.supernews.com...
> lixiaoyao wrote:
>> when I run this code in idl,it generated the following wrong
>> information,what is
>> wrong there?
>> % Compiled module: $MAIN$.
>> % Program caused arithmetic error: Floating illegal operand
>> window,xs=640,ys=480
>> x=10*!pi*findgen(1001)/1000
>> sn=sin(x)/x
>> plot,x,sn
>> end
>> thanks
>>
>
> You're getting it from a floating point divide by zero. When using
> integers, IDL actually tells you that you tried to divide by zero. For
> some reason, they have a different message for floating point.
>
> IDL> x = 0 / 0
> % Program caused arithmetic error: Integer divide by 0
> IDL> x = 0.0 / 0.0
> % Program caused arithmetic error: Floating illegal operand
>
> -Mike
Re: what is Floating illegal operand question? [message #43692 is a reply to message #43691] Mon, 18 April 2005 13:49 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
lixiaoyao wrote:
> when I run this code in idl,it generated the following wrong
> information,what is
> wrong there?
> % Compiled module: $MAIN$.
> % Program caused arithmetic error: Floating illegal operand
> window,xs=640,ys=480
> x=10*!pi*findgen(1001)/1000
> sn=sin(x)/x
> plot,x,sn
> end
> thanks
>

You're getting it from a floating point divide by zero. When using
integers, IDL actually tells you that you tried to divide by zero. For
some reason, they have a different message for floating point.

IDL> x = 0 / 0
% Program caused arithmetic error: Integer divide by 0
IDL> x = 0.0 / 0.0
% Program caused arithmetic error: Floating illegal operand

-Mike
Re: what is Floating illegal operand question? [message #43693 is a reply to message #43692] Mon, 18 April 2005 13:30 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
The first element of sn is 0./0., which is not defined. Haje


"lixiaoyao" <lixiaoyao5880@yahoo.com> wrote in message
news:1113855953.629412.311210@f14g2000cwb.googlegroups.com.. .
> when I run this code in idl,it generated the following wrong
> information,what is
> wrong there?
> % Compiled module: $MAIN$.
> % Program caused arithmetic error: Floating illegal operand
> window,xs=640,ys=480
> x=10*!pi*findgen(1001)/1000
> sn=sin(x)/x
> plot,x,sn
> end
> thanks
>
Re: what is Floating illegal operand question? [message #43694 is a reply to message #43693] Mon, 18 April 2005 13:34 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
AFAIK, IDL does not evaluate any limits. Haje


"lixiaoyao" <lixiaoyao5880@yahoo.com> wrote in message
news:1113855953.629412.311210@f14g2000cwb.googlegroups.com.. .
> when I run this code in idl,it generated the following wrong
> information,what is
> wrong there?
> % Compiled module: $MAIN$.
> % Program caused arithmetic error: Floating illegal operand
> window,xs=640,ys=480
> x=10*!pi*findgen(1001)/1000
> sn=sin(x)/x
> plot,x,sn
> end
> thanks
>
Re: what is Floating illegal operand question? [message #43695 is a reply to message #43693] Mon, 18 April 2005 13:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> when I run this code in idl,it generated the following wrong
> information,what is
> wrong there?
> % Compiled module: $MAIN$.
> % Program caused arithmetic error: Floating illegal operand
> window,xs=640,ys=480
> x=10*!pi*findgen(1001)/1000
> sn=sin(x)/x
> plot,x,sn
> end

IDL> Print, Sin(0)/0
-NaN
% Program caused arithmetic error: Floating illegal operand

Not sure you want to be dividing by zero. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Creating arrays of structures with Callable C
Next Topic: how to draw three-dimension graph using IDL

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

Current Time: Wed Oct 08 16:00:29 PDT 2025

Total time taken to generate the page: 0.00627 seconds