473,412 Members | 2,092 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,412 software developers and data experts.

Bitwise and

I have the following definition in one class

public const Int32 C_RET_ERR_INVALID_BAND = unchecked((int)
0x80080000);

which I am accessing from another class:

string RetValAsString(
Int32 return_value)
{
int l_r = Common.C_RET_ERR_INVALID_BAND;
int l_res = (return_value & l_r);
if (l_res != 0)

When return_value = -7 (0x80000007) I think that I should get l_res == 0, i e

1000 0000 0000 1000 0000 0000 0000 0000
1000 0000 0000 0000 0000 0000 0000 0111
-------------------------------------------------
1000 0000 0000 0000 0000 0000 0000 0000

but I instead get 0x80080000, i e

1000 0000 0000 1000 0000 0000 0000 0000

Where am I doing / thinking wrong?
Aug 16 '06 #1
5 1384
"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:1A**********************************@microsof t.com...
>I have the following definition in one class

public const Int32 C_RET_ERR_INVALID_BAND = unchecked((int)
0x80080000);

which I am accessing from another class:

string RetValAsString(
Int32 return_value)
{
int l_r = Common.C_RET_ERR_INVALID_BAND;
int l_res = (return_value & l_r);
if (l_res != 0)

When return_value = -7 (0x80000007) I think that I should get l_res == 0,
i e
For 0x80080000 & 0x80000007 you should get 0x80000000 not 0. Aside from that
are you sure the values in the vars are correct?

Michael
Aug 16 '06 #2
"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:1A**********************************@microsof t.com...
When return_value = -7 (0x80000007) I think that I should get l_res == 0,
i e
I missed the problem before. -7 is not 0x80000007, it's 0xFFFFFFF9.

Michael
Aug 16 '06 #3
Thanks Michael,

but isn't 0x80000000 for an Int32 equal to 0?
The values are those which come up when I debug.

Regards,
Joachim

"Michael C" wrote:
"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:1A**********************************@microsof t.com...
I have the following definition in one class

public const Int32 C_RET_ERR_INVALID_BAND = unchecked((int)
0x80080000);

which I am accessing from another class:

string RetValAsString(
Int32 return_value)
{
int l_r = Common.C_RET_ERR_INVALID_BAND;
int l_res = (return_value & l_r);
if (l_res != 0)

When return_value = -7 (0x80000007) I think that I should get l_res == 0,
i e

For 0x80080000 & 0x80000007 you should get 0x80000000 not 0. Aside from that
are you sure the values in the vars are correct?

Michael
Aug 16 '06 #4
Ok... Thanks!

"Michael C" wrote:
"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:1A**********************************@microsof t.com...
When return_value = -7 (0x80000007) I think that I should get l_res == 0,
i e

I missed the problem before. -7 is not 0x80000007, it's 0xFFFFFFF9.

Michael
Aug 16 '06 #5
"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:AA**********************************@microsof t.com...
Thanks Michael,

but isn't 0x80000000 for an Int32 equal to 0?
The values are those which come up when I debug.
No, 0x00000000 is 0. 0x80000000 is -2^31.
-1 is 0xFFFFFFFF
-2 is 0xFFFFFFFE
so 0x80000000 is the largest negative value.

Michael
Aug 16 '06 #6

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

Similar topics

6
by: jas_lx | last post by:
The basic understanding of what bitwise operators (& ^ | >> << ) comes fairly simple, as long as one has a fundamental understanding of bits, bytes and binary. Having done some Win32...
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...
8
by: Paul E Collins | last post by:
Suppose I have a few Keys objects: Keys k1 = Keys.V; // V Keys k2 = Keys.Control | Keys.V; // Ctrl+V Keys k3 = Keys.Shift | Keys.J; // Shift+J I need to determine which of these include the...
9
by: Christopher Weaver | last post by:
I know that the bitwise AND of 8 and 4 will return 0 or false and the bitwise AND of 8 and 9 will return 1 or true but I don't know how to write the synax for it in C#. I have a value that ranges...
5
by: noridotjabi | last post by:
I'm learning to program in C and any tutorial or book that I read likes to briefly touch on birdies operators and then move on without giving any sort of example application of them. Call me what...
2
by: Mark Rae | last post by:
Hi, This isn't *specifically* an ASP.NET question, so I've also posted it in the ADO.NET group - however, it's not too far off-topic... Imagine a SQL Server 2005 database with a table with an...
3
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores...
5
by: Gigs_ | last post by:
Can someone explain me bitwise expression? few examples for every expression will be nice x << y Left shift x >y Right shift x & y Bitwise AND x | y Bitwise OR x ^ y Bitwise XOR (exclusive...
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...
29
by: Carl Banks | last post by:
Anyone with me here? (I know the deadline for P3 PEPs has passed; this is just talk.) Not many people are bit-fiddling these days. One of the main uses of bit fields is flags, but that's not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.