fork download
  1. #include <iostream>
  2.  
  3. /* constexpr */ int ftoi(float value)
  4. {
  5. return static_cast<int>(value + (value > 0.0f? 0.5f : -0.5f));
  6. }
  7.  
  8. //Entrypoint to everything.
  9. int main(int argc, char *argv[])
  10. {
  11. std::cout << ftoi(5.454f) << std::endl;
  12. std::cout << ftoi(5.545f) << std::endl;
  13. std::cout << ftoi(-5.454f) << std::endl;
  14. std::cout << ftoi(-5.545f) << std::endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
5
6
-5
-6