473,324 Members | 1,678 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,324 software developers and data experts.

where is the missing bit?

Here is my code:
int main(int argc, char ** argv)
{
cout << "binary representation of 255: " <<
bitset<numeric_limits<int>::digits>(255) << endl;

return 0;
}
//output
binary representation of 255: 0000000000000000000000011111111
What is wrong here? why only 31 bit instead of 32 bits displayed?

thanks
wm

Oct 21 '05 #1
3 1150
we*****@yahoo.com wrote:
Here is my code:
int main(int argc, char ** argv)
{
cout << "binary representation of 255: " <<
bitset<numeric_limits<int>::digits>(255) << endl;

return 0;
}
//output
binary representation of 255: 0000000000000000000000011111111
What is wrong here? why only 31 bit instead of 32 bits displayed?


The sign bit is excluded from 'digits' for signed integral types.

V
Oct 21 '05 #2
In the example of Josuttis's book, it displays 32 bits, how can I
display all the bits including the signed bit?

Oct 21 '05 #3
we*****@yahoo.com wrote:
In the example of Josuttis's book, it displays 32 bits, how can I
display all the bits including the signed bit?


If you're talking about the example on page 462, the types Nicolai
uses are all unsigned (IOW, they don't have the "sign bit"). Yours
is 'int'. You can convert your 'int' to 'unsigned', which should keep
the bit pattern if you're on two's complement machine, and then print
the pattern out but use 'bitset<numeric_limits<unsigned int>::digits>'
to form the bitset.

V
Oct 21 '05 #4

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

Similar topics

4
by: Giganews | last post by:
I have an Access 97 database were I am opening a recordset in a module referencing a control on a form. For some reason when the code executes I am getting an error message stating missing operator...
6
by: MLH | last post by:
If I cut it from the rest of the SQL, the query runs fine. But when I leave the following WHERE clause in there, Access tells me there's a missing Operator? WHERE (((tblVehicleJobs.SerialNum)...
0
by: kris | last post by:
hi can any one help me out, i have written a code for Word Indexing using Dll's i think this is an incomplete code for WORD INDEX. I had encountered this error "Error! No index entries found"...
0
by: Sam | last post by:
Hi, I have a class that receives a DataGrid control and populates it. However, I need to do an OnItemCreated event because if I'm missing data in a certain column, I display a HyperLink control...
13
by: Viken Karaguesian | last post by:
Hello everyone, Can anyone recommend a good online site to learn PHP? The W3Schools website is quite lacking - leaves much to be desired. I'm sure there are many places, but which ones are good?...
2
by: jrjan1 | last post by:
I'm new to c++ and am getting a syntax error: missing ; before } Any help would be greatly appreciated! This is the code - where am I missing the ; ? #ifndef H_addressType #define...
4
by: teddysnips | last post by:
I have a simple table with the following data: fldYear fldCode1 fldCode2 2000 ABC1 ABC12 2000 ABC1 ABC13 2001 ABC1 ABC12 2002 ABC1 ABC12 2002 ...
10
by: kabradley | last post by:
Hey guys, I'm using an embedded sql statement tied to a command button to append records in a certain table. The code for the sql statement is as follows. 'Define sql string strSQL = "INSERT INTO...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I noticed in the toolbox for the VB2005 Report control (RDLC file), the Line tool, Table, Matrix, List tools are all missing. Only the Textbox tool is available and listed for all of the...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.