NearbyInt.sql 660 B

123456789101112131415161718192021222324
  1. $f = ($mode)->{
  2. return (
  3. Math::NearbyInt(Double("NaN"),$mode),
  4. Math::NearbyInt(1e100,$mode),
  5. Math::NearbyInt(2.3,$mode),
  6. Math::NearbyInt(2.5,$mode),
  7. Math::NearbyInt(2.7,$mode),
  8. Math::NearbyInt(3.5,$mode),
  9. Math::NearbyInt(-1e100,$mode),
  10. Math::NearbyInt(-2.3,$mode),
  11. Math::NearbyInt(-2.5,$mode),
  12. Math::NearbyInt(-2.7,$mode),
  13. Math::NearbyInt(-3.5,$mode)
  14. )
  15. };
  16. select $f(Math::RoundDownward()), 0 as x
  17. union all
  18. select $f(Math::RoundToNearest()), 1 as x
  19. union all
  20. select $f(Math::RoundTowardZero()), 2 as x
  21. union all
  22. select $f(Math::RoundUpward()), 3 as x
  23. order by x;