ableos/sysdata/libraries/stn/src/math.hb
2024-09-13 22:41:31 +01:00

15 lines
270 B
Plaintext

shift := 31
// following only work for: int
abs := fn(x: int): int {
mask := x >> shift
return (x ^ mask) - mask
}
min := fn(a: int, b: int): int {
c := a - b
return b + (c & c >> shift)
}
max := fn(a: int, b: uint): int {
c := a - b
return a - (c & c >> shift)
}