Skip to content

Modern Math NegSaturating

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

Home › Math Library › Math Library › NegSaturating

NegSaturating

Negates an integer; the most negative value becomes the maximum instead.

Syntax

NegSaturating( byval a as T ) as T

Notes

  • The most negative value clamps to the maximum instead of staying negative.
  • Every other input negates normally.
  • NegChecked reports that case rather than choosing an answer for you.

Examples

#import "std/numeric"
using numeric

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

dim as int8 ordinary = 100
print NegSaturating( ordinary )               '' -100

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

Clone this wiki locally