Linked Questions

0 votes
5 answers
276 views

Why am I getting an error? It looks pretty straightforward to me. Also, is this the best method for doing what I'm trying to do? #include <iostream> #include <string> int main() { char ...
user2623390's user avatar
0 votes
2 answers
284 views

I am trying to write a file that outputs every possible 16 bit number. I am getting the output in 16 digit hex instead of 16 digit binary. How can I get it in binary. Thank you FILE * file = fopen("...
user2896123's user avatar
0 votes
0 answers
226 views

I have been trying to find the binary representation of negative numbers. As per my knowledge the negative numbers are stored as a 2's complement in the computer. And, the MSB is 1, indicating that it ...
coderzz027's user avatar
0 votes
0 answers
59 views

I have a double variable. Is it possible to output every bit of this variable using char*(char pointer) ? So, char pointer would be char* p = (char*)&myVar; at the beginning and then it will be ...
Aremyst's user avatar
  • 1,528
4 votes
5 answers
13k views

How can I insert a character into a string exactly after 1 character? I need to insert '|' into the string after every other character. In other words (C++): "Tokens all around!" Turns into: "T|o|k|...
CATspellsDOG's user avatar
3 votes
3 answers
22k views

I want to understand how does reading binary files work in C++. My code: int main() { ifstream ifd("input.png",ios::binary |ios::ate); int size = ifd.tellg(); ifd.seekg(0, ios::beg); ...
mrNobody's user avatar
2 votes
2 answers
5k views

I am just trying to do the bitwise complement in C++ with ~ operator: For example: NOT 0101 -------- 1010 So in the following code, I was expecting to get 1010 but I am getting negative numbers. ...
user avatar
4 votes
2 answers
2k views

Writing binary data to a file in C is simple: use fwrite, passing the address of the object you want to write and the size of the object. Is there something more "correct" for Modern C++ or should I ...
hatcat's user avatar
  • 1,926
-2 votes
1 answer
3k views

I want to output an int in 32-bit binary format. Is looping and shifting my only option?
Varaquilex's user avatar
  • 3,473
1 vote
1 answer
2k views

I have to print the binary representation of a long double number for some reasons. I want to see the exact format as it remains in the computer memory. I went through the following questions where ...
Enamul Hassan's user avatar
0 votes
4 answers
4k views

I have an array of 256 unsigned integers called frequencies[256] (one integer for each ascii value). My goal is to read through an input and for each character i increment the integer in the array ...
user0123's user avatar
  • 259
0 votes
2 answers
2k views

I have something like this: template<class T> class SomeClass { public: typedef std::make_unsigned<T> unsigned_t; unsigned_t maxBinBitRep_ { - 1 }; }; int main() { // ...
Francis Cugler's user avatar
0 votes
2 answers
3k views

I already tried looking for this and they gave me to just do along the lines of: int x = 1; while (x != 11) { x = x * 10 + (x+1); } cout<<x; output: 12345678910 While this is good and all ...
Sabishī's user avatar
  • 413
1 vote
2 answers
2k views

I have no choice but to read in 2 bytes that make up a half-float. I would like to work with this in the form of a 4 byte float. Ive done some research and the only thing I can come up with is bit ...
Justin Barren's user avatar
-1 votes
2 answers
3k views

This is what I have for my conversion function so far It takes an unsigned integer as a parameter. It should give the result like outputBinary(1) //=> 0000 0000 0000 0000 0000 0000 0000 0001 ...
Hongyan Wu's user avatar

15 30 50 per page