Bitwise operation returning a long ... how

  • Thread starter Thread starter DaTurk
  • Start date Start date
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?
 
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
 
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
 
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;
 
Back
Top