1
0
Fork 0
forked from AbleOS/ableos
ableos-idl/sysdata/libraries/stn/src/math.hb

14 lines
257 B
Plaintext
Raw Normal View History

SIZEOF_INT := 31
2024-08-20 07:03:39 -05:00
abs := fn(x: int): int {
mask := x >> SIZEOF_INT
2024-08-20 07:03:39 -05:00
return (x ^ mask) - mask
}
min := fn(a: int, b: int): int {
c := a - b
return b + (c & c >> SIZEOF_INT)
}
max := fn(a: int, b: int): int {
c := a - b
return a - (c & c >> SIZEOF_INT)
2024-08-20 07:03:39 -05:00
}