How to round a floating-point number to an integer in Pascal

1 Answer

0 votes
program RoundRFoatingPoint;

var
  y: integer;
  x: double;
  
begin
  x := 9382.4;
  y := round(x);
  WriteLn(y);
  
  x := 9382.5;
  y := round(x);
  WriteLn(y);
  
  x := 9382.6;
  y := round(x);
  WriteLn(y);
  
end.


  
(*
run:
  
9382
9382
9383
  
*)

 



answered May 14, 2025 by avibootz
...