mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
bahaghari/lib: fix math.mod' implementation bug
This commit is contained in:
parent
3f8c59c399
commit
da4a0b8826
@ -278,17 +278,16 @@ rec {
|
||||
let
|
||||
base' = abs base;
|
||||
number' = abs number;
|
||||
difference = number' * ((floor base' / (floor number')) + 1);
|
||||
difference = number' * ((floor (base' / number')) + 1);
|
||||
|
||||
result = number' - (difference - base');
|
||||
result = abs (number' - (difference - base'));
|
||||
in
|
||||
if number' > base' then
|
||||
base
|
||||
if number' > base'
|
||||
then base
|
||||
else
|
||||
if base < 0 then
|
||||
-(result)
|
||||
else
|
||||
result;
|
||||
if base < 0
|
||||
then -(result)
|
||||
else result;
|
||||
|
||||
/* Adds all of the given items on the list starting from a sum of zero.
|
||||
|
||||
|
@ -262,6 +262,11 @@ lib.runTests {
|
||||
expected = 39194.200000000186;
|
||||
};
|
||||
|
||||
testMathMod8 = {
|
||||
expr = self.math.mod' 567.5 3.5;
|
||||
expected = 0.5;
|
||||
};
|
||||
|
||||
testMathModBothPositive = {
|
||||
expr = self.math.mod' 54.5 20.5;
|
||||
expected = 13.5;
|
||||
|
Loading…
Reference in New Issue
Block a user