Reputation: 53
If I print 32700+99 in IDL it gives me -32737 but 33700.0+99 gives me 33799.0. Why is IDL print wrong for 32700+99? Of course 32700.+99 gives, 32799.0, right answer.
Upvotes: 0
Views: 42
Reputation: 2386
The default integer in IDL is 16-bit, so the largest expressible integer is 32767.
IDL> print, 32767
32767
IDL> print, 32767 + 1
-32768
Floats, of course, can handle values in this range. To get a 32-bit integer, use the "L" suffix:
IDL> print, 32767L
32767
IDL> print, 32767L + 1
32768
Upvotes: 1