[Gambas-user] [Gambas Bug Tracker] Bug #1306: Ceil and Floor do not return integer value

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Sun May 6 15:31:13 CEST 2018


http://gambaswiki.org/bugtracker/edit?object=BUG.1306&from=L21haW4-

Comment #1 by Tobias BOEGE:

This is good as it is. The (double) floating point range is wider than the (long) integer range,
so if you went from Float to Long with Ceil, you'd get an overflow where you wouldn't expect it:

  $ gbx3 -e "CLong(Ceil(10e160))"
  -9223372036854775808
  $ gbx3 -e "Ceil(10e160)"
  1E+161

To avoid that, it is best if the result stays as Float. You can convert it to an integer type
yourself using CInt or CLong, after checking the magnitude.

Tobias BOEGE changed the state of the bug to: Rejected.




More information about the User mailing list