forked from AbleOS/ableos
16 lines
406 B
Plaintext
16 lines
406 B
Plaintext
abs := fn($Expr: type, x: Expr): Expr {
|
|
mask := x >> @intcast(@sizeof(Expr) - 1)
|
|
return (x ^ mask) - mask
|
|
}
|
|
min := fn($Expr: type, a: Expr, b: Expr): Expr {
|
|
c := a - b
|
|
return b + (c & c >> @intcast(@sizeof(Expr) - 1))
|
|
}
|
|
max := fn($Expr: type, a: Expr, b: Expr): Expr {
|
|
c := a - b
|
|
return a - (c & c >> @intcast(@sizeof(Expr) - 1))
|
|
}
|
|
|
|
Vec2 := fn($Expr: type): type {
|
|
return struct {x: Expr, y: Expr}
|
|
} |