Skip to content

Modern Math AbsSaturating

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › AbsSaturating

AbsSaturating

Returns the absolute value; the most negative value becomes the maximum instead.

Syntax

AbsSaturating( byval a as T ) as T

Notes

  • The most negative value clamps to the maximum rather than staying negative, which is the least surprising answer available.
  • AbsChecked reports that case instead of papering over it.

Examples

#import "std/numeric"
using numeric

dim as int8 worst = -128
print AbsSaturating( worst ) '' 127 -- clamped, not left negative

dim as int8 ordinary = -5
print AbsSaturating( ordinary )               '' 5

Library: Math Library
Category: Math Library
Documented under: Members

Clone this wiki locally