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

Home » Public Forums » archive » print, long(1.0e10)
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: print, long(1.0e10) [message #16620 is a reply to message #16541] Wed, 04 August 1999 00:00 Go to previous messageGo to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
Gary Fu <gfu@seadas.gsfc.nasa.gov> writes:

> Hi,

> I got different results from the following example on SGI IRIX and PC
> Linux:
> a = 1.0e10
> b = long(a)
> print, b ; 2147483647 for IRIX, -2147483648 for Linux

> It looks like that IRIX and Linux handle it differently when assigning a
> floating value greater (or less) than the boundary of a long integer to
> a long variable. Should I always check the range of 'a' before
> assigning it to a 'long' variable to make the result consistent on IRIX
> and Linux ?

I get yet a different result with IDL/v5.2 on Digital Unix.

IDL> a = 1.0e10
IDL> b = long(a)
% Program caused arithmetic error: Floating illegal operand
% Detected at $MAIN$
IDL> print, b
1410065408

This is a completely sensible result, since it's equal to (A mod 2.^32),
i.e. the 32 lowest most bits of A expressed as an integer.

Since different machines seem to act in different ways, it's best to catch the
error, either by testing the value beforehand, or by using something like
CHECK_MATH.

William Thompson
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL> WHY IS THIS A NULL FILENAME
Next Topic: Re: transfering data files

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

Current Time: Mon Apr 27 09:05:30 PDT 2026

Total time taken to generate the page: 0.72220 seconds