fork download
#include <iostream>
#include <string>
#include <bitset>

std::string PrintBinary(float val)
{
    std::bitset<32> bits(*reinterpret_cast<int *>(&val));
	return bits.to_string();
}

int main ()
{
	double b = 0.0;
	float a = - (float) b;

	std::cout << PrintBinary(a) << std::endl;
	printf("a == %.2f %s 0\n", a, a == 0 ? "==": "!=");
}
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
10000000000000000000000000000000
a == -0.00 == 0