2024-10-12 15:39:09 -05:00
|
|
|
abs := fn($Expr: type, x: Expr): Expr {
|
|
|
|
mask := x >> @intcast(@sizeof(Expr) - 1)
|
2024-08-20 07:03:39 -05:00
|
|
|
return (x ^ mask) - mask
|
|
|
|
}
|
2024-10-12 15:39:09 -05:00
|
|
|
min := fn($Expr: type, a: Expr, b: Expr): Expr {
|
2024-08-30 10:22:13 -05:00
|
|
|
c := a - b
|
2024-10-12 15:39:09 -05:00
|
|
|
return b + (c & c >> @intcast(@sizeof(Expr) - 1))
|
2024-08-30 10:22:13 -05:00
|
|
|
}
|
2024-10-12 15:39:09 -05:00
|
|
|
max := fn($Expr: type, a: Expr, b: Expr): Expr {
|
2024-08-30 10:22:13 -05:00
|
|
|
c := a - b
|
2024-10-12 15:39:09 -05:00
|
|
|
return a - (c & c >> @intcast(@sizeof(Expr) - 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
Vec2 := fn($Expr: type): type {
|
|
|
|
return struct {x: Expr, y: Expr}
|
2024-08-20 07:03:39 -05:00
|
|
|
}
|