tools: add floatTruncate function

This commit is contained in:
Rodrigo Arias 2021-04-16 11:49:37 +02:00
parent 4d629fe8f7
commit 9bb570af7f

View File

@ -77,6 +77,14 @@ let
optionalInherit = l: a: filterAttrs (n: v: v!=null) optionalInherit = l: a: filterAttrs (n: v: v!=null)
(overrideExisting (genNullAttr l) a); (overrideExisting (genNullAttr l) a);
# Given a float f, truncates it and returns the resulting the integer
floatTruncate = f: let
strFloat = toString f;
slices = splitString "." strFloat;
front = elemAt slices 0;
in
toInt front;
}; };
in in
gen gen