![]() |
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. |
It could be scripted quite easily, any negative number shifted right once becomes positive, with which you can just use the normal shift operator.
|
| All times are GMT +2. The time now is 11:26 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.