0

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.

veda905
  • 782
  • 2
  • 12
  • 32
SUV
  • 53
  • 6

1 Answers1

1

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
mgalloy
  • 2,356
  • 1
  • 12
  • 10