Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "rint"

From Quake Wiki

m (Move page script moved page Rint to rint: Fixing the case)
 
Line 1: Line 1:
float '''rint'''(float ''val'')
+
''float'' '''rint'''(''float'' val)
  
Returns ''val'', rounded up to the closest integer value.
+
== Usage ==
 +
Rounds the passed number to the nearest whole number.
 +
 
 +
=== Parameters ===
 +
*''val''
 +
:The number to round.
 +
 
 +
=== Return ===
 +
Returns the rounded number.
 +
 
 +
== Example ==
 +
// Performs an action with a 50/50 chance
 +
float chance = random();
 +
if (rint(chance))
 +
    DoAction();

Latest revision as of 12:37, 1 August 2023

float rint(float val)

Usage[edit]

Rounds the passed number to the nearest whole number.

Parameters[edit]

  • val
The number to round.

Return[edit]

Returns the rounded number.

Example[edit]

// Performs an action with a 50/50 chance
float chance = random();
if (rint(chance))
    DoAction();