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