Stewart Gordon wrote:
#include
int main() {
unsigned char z = 5;
int x = -z; // x now is 251
Needless to say, this comment is a mistake.
Stewart.
Moritz Warning wrote:
ubyte z = 5;
int x = -z; // x now is 251
int y = -1 * z; // y is now -5
Indeed, I've just looked at the spec, and it appears that the promotion
of all smaller integer types to int/uint applies only to binary
operations. Why?
It even arguably breaks the "looks like C,
On Fri, 02 Oct 2009 16:25:01 +0200, Don wrote:
> Brad Roberts wrote:
>> On Thu, 1 Oct 2009, Saaa wrote:
>>
>>> I think is very bug-prone, isn't it obvious iub should be -5?
>>>
>>> ubyte ub = 5;
>>> int iub = -ub; // iub now is 251
>>>
>>> What is the reasoning to do it this way?
>>
>> The inclu
Brad Roberts wrote:
On Thu, 1 Oct 2009, Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
The inclusion of the 'int' part obscures what I think the real problem
is..
Does
Jeremie Pelletier wrote:
Don wrote:
Saaa wrote:
Jeremie Pelletier wrote
Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
Minus toggles the most significant bit, be it on a signed
Don wrote:
Saaa wrote:
Jeremie Pelletier wrote
Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
Minus toggles the most significant bit, be it on a signed or unsigned
type. When c
Saaa wrote:
Jeremie Pelletier wrote
Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
Minus toggles the most significant bit, be it on a signed or unsigned
type. When converting it
On Thu, 1 Oct 2009, Saaa wrote:
> I think is very bug-prone, isn't it obvious iub should be -5?
>
> ubyte ub = 5;
> int iub = -ub; // iub now is 251
>
> What is the reasoning to do it this way?
The inclusion of the 'int' part obscures what I think the real problem
is..
Does it make sense
On Thu, Oct 1, 2009 at 2:00 PM, bearophile wrote:
> I have discussed such topics several times in the main D newsgroup, and in
> the end no good solution has being found/accepted so far. But eventually some
> better solution must be found...
Fucking A, bearophile. Bugzilla. How many fucking ti
Saaa:
>Does anybody ever use the =-z behaviour?<
Sometimes C programmers use something like:
unsigned int x = -1;
The interaction of signed-unsigned integral numbers in D is very error-prone,
so much that I suggest to use unsigned integrals in D only where strictly
necessary (generally when you
Moritz Warning wrote
>
> This is a troublesome behavior:
>
> ubyte z = 5;
> int x = -z; // x now is 251
> int y = -1 * z; // y is now -5
Yes, troublesome is the correct word :)
Does anybody ever use the =-z behaviour?
On Thu, 01 Oct 2009 10:16:08 -0400, Jeremie Pelletier wrote:
> Saaa wrote:
>> I think is very bug-prone, isn't it obvious iub should be -5?
>>
>> ubyte ub = 5;
>> int iub = -ub; // iub now is 251
>>
>> What is the reasoning to do it this way?
>
> Minus toggles the most significant bit, be it on
Jeremie Pelletier wrote
>
> Then why use an ubyte instead of a byte or an int?
I wasn't me who wrote that part of the code :)
>
> You could also just do:
> for(int i = cast(byte)nloop; i < 10; i++)
I forgot the minus sign:
for(int i = -cast(int)nloop;i< 10; i++)
Still think it is unnecessary bug-
Saaa wrote:
Jeremie Pelletier wrote
Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
Minus toggles the most significant bit, be it on a signed or unsigned
type. When converting it
Jeremie Pelletier wrote
> Saaa wrote:
>> I think is very bug-prone, isn't it obvious iub should be -5?
>>
>> ubyte ub = 5;
>> int iub = -ub; // iub now is 251
>>
>> What is the reasoning to do it this way?
>
> Minus toggles the most significant bit, be it on a signed or unsigned
> type. When conv
Saaa wrote:
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
Minus toggles the most significant bit, be it on a signed or unsigned
type. When converting it to an int, the byte being signed o
I think is very bug-prone, isn't it obvious iub should be -5?
ubyte ub = 5;
int iub = -ub; // iub now is 251
What is the reasoning to do it this way?
17 matches
Mail list logo