[Issue 3583] New: Unsigned right shift works the same as signed right shift.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 6 12:15:19 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3583
Summary: Unsigned right shift works the same as signed right
shift.
Product: D
Version: future
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2009-12-06 12:15:14 PST ---
import std.stdio;
void main() {
int i = 0b10000000_00000000_00000000_00000010;
int iSigned = i >> 2;
writefln(" int >>: %.32b", iSigned);
int iUnsigned = i >>> 2;
writefln(" int >>>: %.32b", iUnsigned);
uint u = cast(uint) i;
uint uSigned = u >> 2;
writefln(" uint >>: %.32b", uSigned);
uint uUnsigned = u >>> 2;
writefln("uint >>>: %.32b", uUnsigned);
}
Output (DMD 2.037):
int >>: 11100000000000000000000000000000
int >>>: 11100000000000000000000000000000
uint >>: 00100000000000000000000000000000
uint >>>: 00100000000000000000000000000000
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list