Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <bitset>
- #include <cstdint>
- std::string toBinaryString(double value)
- {
- union
- {
- double d;
- uint64_t i;
- } u;
- u.d = value;
- std::bitset<64> b(u.i);
- return b.to_string();
- }
- int main(int argc, char* argv[])
- {
- double value = 123.456;
- std::cout << toBinaryString(value) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement