From 9bb570af7f58b95e410ae2fe4f9c4121fd83fafb Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 16 Apr 2021 11:49:37 +0200 Subject: [PATCH] tools: add floatTruncate function --- garlic/tools.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/garlic/tools.nix b/garlic/tools.nix index 836ee73..db9c2a7 100644 --- a/garlic/tools.nix +++ b/garlic/tools.nix @@ -77,6 +77,14 @@ let optionalInherit = l: a: filterAttrs (n: v: v!=null) (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 gen