How to ignore the decimals of a number in godot 3?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By arthurZ

Hi, I want to know how to ignore the decimals of a number. I’m not talking about rounding it.
For example (for this case):
Wrong: 8.83 = 9
Correct: 8.83 = 8


:bust_in_silhouette: Reply From: ralle

maybe by using floor

floor ( float s )

floor returns a rounded result. He asked for a result that ignores decimals and keeps the whole number. int(3.55)would return 3 while floor(3.55) would return 4

rz | 2022-07-16 21:04

:bust_in_silhouette: Reply From: rolfpancake

Explicit type conversion:

var i = int(8.83)

Docs of the int-class are very clear here:

int int ( float from )

Cast a float value to an integer value, this method simply removes the number fractions, so for example int(2.7) will be equals to 2, int(.1) will be equals to 0 and int(-2.7) will be equals to -2.