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

Home » Public Forums » archive » Absolute value of negative number is negative
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Absolute value of negative number is negative [message #92691] Mon, 08 February 2016 11:00 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I was surprised to find that taking the absolute value of a 16 bit integer vector was yielding negative numbers.
While this is non-intuitive, I think it is unavoidable. --Wayne


IDL> tab= -32768S ;IDL won't let us define -32768 as a short integer

tab= -32768
^
% Integer constant must be less than 32768.

IDL> tab = intarr(1) ;but we can assign a short integer to -32768
IDL> tab[0] = -32768
IDL> help,tab ;Still a short integer
TAB INT = Array[1]
IDL> print,tab[0] ;Still a value of -32768
-32768
IDL> print,abs(tab[0]) ;Absolute value is negative!
-32768
[Message index]
 
Read Message
Read Message
Previous Topic: AIRMASS
Next Topic: NCDF_IS_NCDF

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

Current Time: Wed Oct 08 15:57:56 PDT 2025

Total time taken to generate the page: 0.00457 seconds