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).

int y = (int)x;
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;
var
  y: integer;
  x: single = -0.8;
begin
  y := trunc(x);
end;
my $y = int($x);
y = int(x)
y = x.to_i
let y = x as i32;

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