1
0
Fork 0
forked from AbleOS/ableos
ableos-idl/sysdata/libraries/stn/src/math.hb
koniifer 12ee3a9b87 fix random
implement hardware_random_u32
implement math.max, alter math.min
remove unneeded dependencies from fb_driver
2024-08-30 16:22:13 +01:00

14 lines
257 B
Plaintext

SIZEOF_INT := 31
abs := fn(x: int): int {
mask := x >> SIZEOF_INT
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)
}