Bitwise operation returning a long ... how

D

DaTurk

int number = 0;
int result = 0;

result = number | 0x80000000

Why is the compiler telling me this is converting a long to an int.
Where's the long? 0x80000000 is 32 bits, what am I missing?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

DaTurk said:
int number = 0;
int result = 0;

result = number | 0x80000000

Why is the compiler telling me this is converting a long to an int.
Where's the long? 0x80000000 is 32 bits, what am I missing?

0x80000000 is an uint (not an int).

And apperently int | uint gives a long.

Arne
 
M

Michael C

Arne Vajhøj said:
0x80000000 is an uint (not an int).

And apperently int | uint gives a long.

This is a bit of a pita in C# imo when defining constants etc.

Michael
 
B

Ben Voigt [C++ MVP]

DaTurk said:
int number = 0;
int result = 0;

result = number | 0x80000000

Why is the compiler telling me this is converting a long to an int.
Where's the long? 0x80000000 is 32 bits, what am I missing?

If you think that's fun, try:

byte a, b, c;
a = 1;
b = 5;
c = a & b;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top