Files
nix-stuff/vaculib/math.nix
Shelvacu 6ab9c8178d stuff
2025-08-26 23:39:44 -07:00

18 lines
378 B
Nix

{
...
}:
rec {
# https://github.com/NixOS/nixpkgs/issues/41251#issuecomment-393660714
pow = base: exponent:
if exponent > 0 then
let
and1 = x: (x / 2) * 2 != x;
x = pow base (exponent / 2);
in
x * x * (if and1 exponent then base else 1)
else if exponent == 0 then
1
else
throw "undefined";
}