473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Bitwise operation returning a long ... how

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?

Aug 27 '07 #1
3 1498
DaTurk wrote:
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
Aug 27 '07 #2
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:46***********************@news.sunsite.dk...
>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.
This is a bit of a pita in C# imo when defining constants etc.

Michael
Aug 27 '07 #3

"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
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;
Aug 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jerry | last post by:
I want an algorithm that do arithmetic operations(divide,mutiply,add etc.)just using bitwise operators:<<,>>,&,|,^; For example,how "a/10" can be implemented. I just want a hint. Thanks.
2
by: Steve Summit | last post by:
-----BEGIN PGP SIGNED MESSAGE----- It's often explained that the reason for some of the imprecision in C's definition is so that C can be implemented on different kinds of machines -- say, those...
6
by: gilad | last post by:
I am trying to return 8 bytes (64 bits) as a 'long' from a file my program is reading. The logic I am using is below: return (long)( ((inBytes & 255) << 56) | ((inBytes & 255) << 48) |...
3
by: Marc | last post by:
I'm trying to set the first three bits to zero on a byte. For some reason, the compiler is casting the number peculiarly when I use the bitwise complement operator. Here's what I think should...
20
by: oswald.kluge | last post by:
Dear Reader, what efficient ways are there to OR two large memory regions? I'm especially interested in applying this operation to two large character arrays. I know memset and memcopy lets...
45
by: Carramba | last post by:
Hi! I now that I can't do straight forward any bitwise operation on float (double etc..). But I wondering what is the easiest/best way to do this? I was thinking if I have float x=1.1111 so I can...
4
by: loudking | last post by:
Hello, all. I am not good at bitwise operation, so I wonder if some experts could do me a help. In a.c, somebody defined ================================================ # define u_int64...
5
by: Rahul | last post by:
Hi Everyone, I have a program unit which does >and << of an integer which is of 4 bytes length. The logic of shifting and action based on the result, assumes that the system is big-endian. ...
3
by: Sakhtkoosh | last post by:
I have written a program in C environment. I need to do operation on codes with more than 64 elements whose values are 0 and 1. At first, I simulated it with an array in 2 dimension(n*m) but after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.