chessai / nix-std

no-nixpkgs standard library for the nix expression language
105 stars 7 forks source link

num.pow using exponentiation by squaring #49

Closed CRTified closed 1 year ago

CRTified commented 1 year ago

This PR changes the naive method of computing the power of some number to the more efficient exponentiation by squaring.

It is likely that this is completely unnecessary as a change, as nix only supports single-precision 64 bit integers so far. If this changes at some time in the future, this would be more robust.

Tests remain successful for me.

chessai commented 1 year ago

Can you add more "varied" tests here: https://github.com/chessai/nix-std/blob/master/test/sections/num.nix#L73

CRTified commented 1 year ago

Are these tests sufficient, or did you have something else in mind?

And should I squash the commits for a cleaner history?

chessai commented 1 year ago

Are these tests sufficient, or did you have something else in mind?

And should I squash the commits for a cleaner history?

I'll squash when I merge

chessai commented 1 year ago

This looks good