Skip to content

Instantly share code, notes, and snippets.

@usagi
Created April 18, 2014 07:20
Show Gist options
  • Select an option

  • Save usagi/11029093 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/11029093 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
auto main() -> int
{
std::cout
<< std::setprecision(32)
<< std::fixed
<< 0.123456789012345678901234567890123456789f << "\n"
<< 0.123456789012345678901234567890123456789 << "\n"
<< 0.123456789012345678901234567890123456789l << "\n"
;
}
LH-MAIN /home/usagi/tmp/floating.cxx
<< cat floating.cxx [master]
#include <iostream>
#include <iomanip>
auto main() -> int
{
std::cout
<< std::setprecision(32)
<< std::fixed
<< 0.123456789012345678901234567890123456789f << "\n"
<< 0.123456789012345678901234567890123456789 << "\n"
<< 0.123456789012345678901234567890123456789l << "\n"
;
}% LH-MAIN /home/usagi/tmp/floating.cxx
<< clang++11.debug floating.cxx [master]
LH-MAIN /home/usagi/tmp/floating.cxx
<< ./a.out [master]
0.12345679104328155517578125000000
0.12345678901234567736988623209982
0.12345678901234567890132180073559
LH-MAIN /home/usagi/tmp/floating.cxx
<< em++11.debug floating.cxx [master]
LH-MAIN /home/usagi/tmp/floating.cxx
<< nodejs a.out.js [master]
0.12345679104328155518000000000000
0.12345678901234567737000000000000
0.12345678901234567737000000000000
LH-MAIN /home/usagi/tmp/floating.cxx
<<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment