This language bar is your friend. Select your favorite languages!

Idiom #80 Truncate floating point number to integer

Declare integer y and initialize it with the value of floating point number x . Ignore non-integer digits of x .
Make sure to truncate towards zero: a negative x must yield the closest greater integer (not lesser).

y = x.to_i
int y = cast(int)x;
int y = x.toInt()
y = trunc(x)
y := int(x)
y = truncate x
int y = (int)x;
y = math.modf(x)
$y = (int)$x;
  y: integer;
  x: single = -0.8;
  y := trunc(x);
my $y = int($x);
y = int(x)
let y = x as i32;

Do you know the best way to do this in your language ?
New implementation...