Negative shifting bitsum.
Dose negative bitsums shifting works?
For example PHP Code:
ID'S Code:
Or this is how it works :- by shifting to the right (1>>0) = 1/2 = 0.5 |
Re: Negative bitsum.
In C it's undefined behavior, and since Pawn's left shift directly translates to C's, it should be undefined behavior too.
|
Re: Negative bitsum.
Quote:
|
Re: Negative shifting bitsum.
Quote:
|
Re: Negative shifting bitsum.
Quote:
and what about (x>>1) = ? what dose it equal to? && btw shifting negative gives results, it dosen't throw an error! (1<<-1) & (1<<0) = 0 |
Re: Negative shifting bitsum.
There's applications of right shifting, it's the opposite of left shifting. Can't think of any right now but I've been using it.
I never said it will throw an error, it's just undefined behavior - the result is not defined by the standard. |
Re: Negative shifting bitsum.
Quote:
|
Re: Negative shifting bitsum.
Hence there is no reason to do it. If you shift negative places then your code has a flaw and you should fix it.
|
Re: Negative shifting bitsum.
Quote:
|
| All times are GMT -4. The time now is 18:01. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.