D arithmetic problem
    Denis Koroskin 
    2korden at gmail.com
       
    Wed Jun  3 06:52:12 PDT 2009
    
    
  
On Wed, 03 Jun 2009 06:45:10 +0400, davidl <davidl at nospam.org> wrote:
> Following two piece of code demonstrate different behaviors currently.
>
> import std.stdio;
> void main()
> {
> 	uint v;
> 	v=31234;
> 	byte t= -1;
> 	v |= t;
> 	writefln(v);
> }
>
> Output:4294967295
>
> import std.stdio;
> void main()
> {
> 	uint v;
> 	v=31234;
> 	byte t= -1;
> 	v |= cast(ubyte)t;
> 	writefln(v);
> }
>
> Output:31487
>
> I would always want the second result. What's your opinion?
>
>
Shouldn't bitwise operations be disallowed on signed types at all?
    
    
More information about the Digitalmars-d
mailing list