[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: print, long(1.0e10)
- Subject: Re: print, long(1.0e10)
- From: thompson(at)orpheus.nascom.nasa.gov (William Thompson)
- Date: 9 Aug 1999 16:31:32 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
- References: <37A7617E.9F5DD25D@seadas.gsfc.nasa.gov>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:16043
Gary Fu <gfu@seadas.gsfc.nasa.gov> writes:
>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 ?
It appears that Digital Unix gives yet another answer:
IDL> a = 1.0e10
IDL> b = long(a)
% Program caused arithmetic error: Floating illegal operand
IDL> print, b
1410065408
which makes sense, since that's A modulo 2^32.
William Thompson