online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <algorithm> template <typename T> void show(T d) { unsigned char arr[sizeof(T)]; std::copy(reinterpret_cast<const unsigned char*>(&d), reinterpret_cast<const unsigned char*>(&d) + sizeof(T), &arr[0] ); std::cout << d << ", size: " << sizeof(T) << "\n"; std::cout << std::hex ; for (auto byte : arr) { std::cout << +byte << ' '; } std::cout << "\n double: " << std::dec << d << ", int: " << (int)d << "\n-----------------\n"; } int main() { double d = 99.98; double x = 100 - d; x *= 100; show(x); // 2 show(2.0); // 2 show(100 - d); // 0.02 show(0.02); // 0.02 double d1 = 99.97; d1 = 100 - d1; d1 *= 100; show(d1); //1 show(3.0); //1 }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue