在 Wed, 03 Jun 2009 10:48:02 +0800,Tim Matthews <[email protected]>
写道:
davidl 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?
should be in d.learn but try this:
import std.stdio;
void main()
{
uint v;
v=31234;
ubyte t= -1;
v |= t;
writefln(v);
}
I mean the first behavior can cause problems. I doubt any coder would try
to get that result by writing that piece of code. I ported some C# source
to D, and I got this semantic different issue.
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/