From 3af9ba3c4b56327bbacc1b2812dbf1cf794a7cfc Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 23 Dec 2023 14:05:35 +0200 Subject: Add gnosis-review-round Function to round arg to 1 decimal. Used for calculating new easiness factor (ef/new-ef) --- gnosis.el | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gnosis.el b/gnosis.el index e6ceb36..ddfeae9 100644 --- a/gnosis.el +++ b/gnosis.el @@ -181,15 +181,13 @@ Returns a list of the form ((yyyy mm dd) ef)." (let ((last-rev (gnosis-get 'last-rev 'review-log `(= id ,id)))) (gnosis-algorithm-date-diff last-rev))) -(defun gnosis-review--new-ef (id success) - "Update ef for note with value of id ID. - -SUCCESS is a binary value, 1 = success, 0 = failure." - (cl-assert (or (equal success 1) (equal success 0))) - (let ((ef (gnosis-review--algorithm id success))) - (if (equal success 1) - (nth 0 ef) - (nth 1 ef)))) +(defun gnosis-review-round (num) + "Round NUM to 1 decimal. + +This function is used to round floating point numbers to 1 decimal, +such as the easiness factor (ef)." + (/ (round (* num 100.00)) 100.00)) + (defun gnosis-review--success (id) "Update review-log for note with value of id ID." -- cgit v1.2.3