Last active
November 16, 2015 08:07
-
-
Save tomilov/93ba09f45d2625f5579d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <cstdint> | |
#include <cstdlib> | |
int | |
main() | |
{ | |
auto const x = -10000000000000000.0L; | |
union | |
{ | |
std::uint8_t in[10]; | |
struct | |
{ | |
std::uint64_t out8; | |
std::uint8_t out1; | |
unsigned : 7; | |
unsigned sign : 1; | |
}; | |
}; | |
asm("fld %1\n" "fbstp %0" : "=m"(in) : "f"(x) : "memory"); | |
std::cout << std::hex << std::noshowbase; | |
if (sign != 0) { | |
std::cout << '-'; | |
} | |
if (out1 != 0) { | |
std::cout << std::uint16_t(out1) << std::setfill('0') << std::setw(16); | |
} | |
std::cout << out8 << std::endl; | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment