Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
Y : constant Integer := Integer (Float'Rounding (X));
(defn rnd [y] (int (+ y 0.5)))
var y = x.round();
y = Kernel.round x
integer :: y
y = nint(x)
y = floor (x + 1/2)
var y = Math.round(x);
long y = Math.round(x);
(defun rnd (y) (floor (+ y 0.5)))
function round(float)
local int, part = math.modf(float)
if float == math.abs(float) and part >= .5 then return int+1 -- positive float
elseif part <= -.5 then return int-1 -- negative float
end
return int
end
function round(float)
return math.floor(float + .5)
end
$y = (int) round($x);
var
y: integer;
x: double;
begin
y := round(x);
end.
my $y = int($x + 1/2);
y = int(x + 0.5)
y = (x + 1/2r).floor
let y = x.round() as i64;
(define y (round x))