ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:clamp

Table of Contents

clamp

num clamp(num x, num a, num b)

num - any numeric type (int or fixed)

Description

Limits x to the range [a; b]. If x falls in the range, returns x.

If x is less than a, returns a.

If x is greater than b, returns b.

Examples

clamp(7, 6, 8) -> 7
clamp(5, 6, 8) -> 6
clamp(8, 6, 8) -> 8

clamp(0.25, 0.2, 0.3) -> 0.25
clamp(0.15, 0.2, 0.3) -> 0.2
clamp(0.35, 0.2, 0.3) -> 0.3
functions/clamp.txt · Last modified: 2017/03/15 10:36 by korshun