[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print, long(1.0e10)

Gary Fu <gfu@seadas.gsfc.nasa.gov> writes:

>I got different results from the following example on SGI IRIX and PC
>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

which makes sense, since that's A modulo 2^32.

William Thompson