Jump to content

Abs()

From OpenBOR
Revision as of 14:18, 21 July 2026 by Dcurrent (talk | contribs) (Created page with "Accepts a numeric value and returns its absolute value - its non-negative magnitude without regard to sign. Integer inputs return an integer, while decimal inputs return a decimal. '''Whole'''<syntaxhighlight lang="c" line="1">int input = -5; int result = abs(input); // result = 5</syntaxhighlight>'''Decimal'''<syntaxhighlight lang="c" line="1"> float input = -3.8; float result = abs(input); // result = 3.8 </syntaxhighlight> Category:OpenBOR Index Category:Sc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Accepts a numeric value and returns its absolute value - its non-negative magnitude without regard to sign. Integer inputs return an integer, while decimal inputs return a decimal.

Whole

int input = -5;

int result = abs(input);

// result = 5

Decimal

float input = -3.8;

float result = abs(input);

// result = 3.8