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

Home » Public Forums » archive » strange GT and LT behavior
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
strange GT and LT behavior [message #89468] Mon, 20 October 2014 08:41 Go to previous message
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
I've encountered a bizarre situation where IDL thinks that 0 is less than a negative number. Can anyone rationalize this? Is it really not ok to compare the value of an unsigned integer with a signed integer? Shouldn't the compiler handle this?

test case:

pro test_gt_lt

a = ulong64(0)

b = long(100)

if (a lt b) then begin

print, 'ZERO IS LESS THAN 100'

endif else begin

print, 'ZERO IS GREATER THAN 100'

endelse


c = ulong64(0)

d = long(-100)

if (c lt d) then begin

print, 'ZERO IS LESS THAN -100'

endif else begin

print, 'ZERO IS GREATER THAN -100'

endelse

end

OUTPUT:
ZERO IS LESS THAN 100
ZERO IS LESS THAN -100

IDL> print, !version
{ x86_64 Win32 Windows Microsoft Windows 8.3 Nov 15 2013 64 64}

thanks
Mark
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: cgWindRose has error producing legend?
Next Topic: save contour to eps in 8.2.3

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

Current Time: Wed Oct 08 15:08:03 PDT 2025

Total time taken to generate the page: 0.00364 seconds