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

Difference between revisions of "fabs"

From Quake Wiki

m (Spirit moved page Fabs to fabs: lowercase)
 
Line 1: Line 1:
float '''fabs'''(float ''val'')
+
''float'' '''fabs'''(''float'' val)
  
Returns absolute value of ''val'' (like the equivalent function in C).
+
== Usage ==
 +
Gets the absolute value of a number.
 +
 
 +
=== Parameters ===
 +
*val
 +
:The number to get the absolute value of.
 +
 
 +
=== Return ===
 +
The absolute value of the passed number.
 +
 
 +
== Example ==
 +
// If the offset is large enough, do a special action
 +
float offset = crandom() * 5;
 +
if (fabs(offset) > 2.5)
 +
    DoSpecialAction();
 +
 +
spread.x *= offset;
 +
spread.y *= offset;

Latest revision as of 13:10, 1 August 2023

float fabs(float val)

Usage[edit]

Gets the absolute value of a number.

Parameters[edit]

  • val
The number to get the absolute value of.

Return[edit]

The absolute value of the passed number.

Example[edit]

// If the offset is large enough, do a special action
float offset = crandom() * 5;
if (fabs(offset) > 2.5)
    DoSpecialAction();

spread.x *= offset;
spread.y *= offset;