Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-06-2006, 03:06 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Unsigned Bitwise Right Shift

lets pretend we're working with 8 bits.

11111111 = -1
-1 >> n = 11111111

I want to be able to do this:
-1 >> 7 = 00000001

In C++ this type of thing is handled by having an unsigned int.

In Java, (wow, something actually more flexible than C++?), this type of thing is handled by the >>>, >>>= operators (the extra >). It's unsigned right shift and unsigned right shift assignment.

so the above statement would actually look like this:

-1 >>> 7 (gives you 00000001)

So the addition of the unsigned right shift operator to gscript would be great.
Thanks.

Well, reading that you're checking compatibility with C code for bit shifts, it might actually be difficult to do this. C uses an unsigned type which would imply to always fill with zeros. You'd have no way of performing such an operation like this with signed types in C++. Meanwhile, a lot of scripting languages only have signed ints, so they use >>> when they want to accomplish this.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.