Script API: add a equivalent of "truncate" to FloatToInt modes #1983
Labels
ags 4
related to the ags4 development
context: script api
type: enhancement
a suggestion or necessity to have something improved
FloatToInt currently supports 3 modes:
floor
(or C++ std::floor): it finds the closest integer literally <= than the given float.ceil
: it finds the closest integer >= given float.round
: it rounds to the closest integer.What is missing here is "truncate": the one that finds a closest integer which is less by magnitude. We may call this eRoundTruncate (unless someone suggests a better name).
The difference between
floor
andtrunc
is that for the floor (eRoundDown):+1.5 = +1
-1.5 = -2
and for trunc (eRoundTruncate):
+1.5 = +1
-1.5 = -1
NOTE: also, the FloatToInt implementation in the engine should be rewritten to use libc or std C++ functions.doneEDIT: In fact, we might also add a mode opposite to "truncate", which finds nearest integer greater by magnitude. The C/C++ do not have the ready function for this, but it may be implemented like
The text was updated successfully, but these errors were encountered: