Can you have bitset container of floating data types? Example:
bitset<sizeof(float)*sizeof(char)> second(5.5f);
cout << second.to_string() << endl;
It doesn’t work correctly. what i’m trying to do is get the bit representation.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
bitsetonly takes aunsigned longas its constructor argument. In your example thefloatis converted tounsigned longand then used as the argument.To get what you desire use something along the lines of:
This reinterprets the “memory” the float is in as memory containing an
unsigned longand thus “tricks” the constructor.