summaryrefslogtreecommitdiff
path: root/libk/src/math/fclamp.c
blob: f757b48250006c97f518cc53bcd7404d37ccb4a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <math.h>

double fclamp(double x, double l, double h) {
    if (x < l) return l;
    if (x > h) return h;
    return x;
}

float fclampf(float x, float l, float h) {
    if (x < l) return l;
    if (x > h) return h;
    return x;
}