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

Difference between revisions of "ceil"

From Quake Wiki

m (Move page script moved page Ceil to ceil: Fixing the case)
 
Line 1: Line 1:
float '''ceil'''(float ''val'')
+
''float'' '''ceil'''(''float'' val)
  
Returns ''val'', rounded up to the integer above (like the equivalent function in C).
+
== Usage ==
 +
Rounds the passed number up to the next highest whole number.
 +
 
 +
=== Parameters ===
 +
*''val''
 +
:The number to round up.
 +
 
 +
=== Return ===
 +
Returns the rounded up number.
 +
 
 +
== Example ==
 +
// Add a random amount of stacks, guaranteeing it always adds at least one
 +
float toAdd = random() * 5;
 +
self.stacks += ceil(toAdd);

Latest revision as of 12:43, 1 August 2023

float ceil(float val)

Usage[edit]

Rounds the passed number up to the next highest whole number.

Parameters[edit]

  • val
The number to round up.

Return[edit]

Returns the rounded up number.

Example[edit]

// Add a random amount of stacks, guaranteeing it always adds at least one
float toAdd = random() * 5;
self.stacks += ceil(toAdd);