Graal Forums  

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

Thread Tools Search this Thread Display Modes
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.

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
Old 11-07-2006, 12:49 AM
Tolnaftate2004 Tolnaftate2004 is offline
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
It could be scripted quite easily, any negative number shifted right once becomes positive, with which you can just use the normal shift operator.
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:16 PM.

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