fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. float f = 94.12345f;
  6. long long n = f * 1000000000LL;
  7. std::cout << "float: " << n << '\n';
  8. n = (f + 0.0000005) * 1000000;
  9. n *= 1000LL;
  10. std::cout << "rounded: " << n << '\n';
  11. return 0;
  12. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
float: 94123450368
rounded: 94123451000