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

Home » Public Forums » archive » -32768
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: -32768 [message #88131 is a reply to message #88122] Sat, 22 March 2014 13:20 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Friday, March 21, 2014 11:02:08 AM UTC-7, Yngvar Larsen wrote:
> On Friday, 21 March 2014 00:44:17 UTC+1, Chris Torrence wrote:
>> On Thursday, March 20, 2014 3:30:49 PM UTC-6, Yngvar Larsen wrote:
>
>> Jim P. is correct that the minus sign is really an operator. So it really is a runtime error to write "a = 32768s", regardless of whether you are then going to take the negative of it.
>
>
>
> Fair enough. In that case, what is missing is a way to enter a literal negative number. "-376768" _is_ a valid 16-bit signed integer after all! Not really a problem, since negation of a single number hardly is a big performance hit... Also, the OPs problem hasn't hit me at all during the 15+ years I've been using IDL. And there are at least 3 simple (bit silly) workarounds, already mentioned in this thread.

And for our further pedantry, if you really need to know which is most time efficient (at least on my MacBook, IDL 8.2):

IDL> tic & for i=1,1e7 do a=FIX(-32768) & toc
% Time elapsed: 1.7954290 seconds.

IDL> tic & for i=1,1e7 do a=FIX('8000'X) & toc ; Hex code depends on hardware "endian-ness"
% Time elapsed: 1.4319592 seconds.

IDL> tic & for i=1,1e7 do a=not 32767S & toc
% Time elapsed: 1.1942451 seconds.

IDL> tic & for i=1,1e7 do a=-32767S-1S & toc ; The winner!
% Time elapsed: 1.1435649 seconds.

Notice how much longer this takes compared to a simple, positive literal:

IDL> tic & for i=1,1e7 do a=32767S & toc
% Time elapsed: 0.39454412 seconds.

Cheers,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- www.d-jackson.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Killing Widget Objects
Next Topic: How to choose the pixels along a curve in an image

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

Current Time: Wed Oct 08 15:49:41 PDT 2025

Total time taken to generate the page: 0.00208 seconds