Coverage report: /development/source/library/com/dydra/gitlab/dydra-cgi/ffi/lisp/dydra-ndk/util.lisp
| Kind | Covered | All | % |
| expression | 0 | 46 | 0.0 |
| branch | 0 | 6 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
(in-package :dydra-ndk)
3
;; https://github.com/dryproject/snippets/blob/master/common-lisp/parse-decimal.lisp
4
(defun parse-decimal (input-string)
5
"Parses a decimal string, returning the corresponding rational number."
6
(declare (type string input-string))
7
(let* ((separator-position (or (position #\. input-string) 0))
8
(start (if (eql (char input-string 0) #\-) 1 0))
9
(integer-part (parse-integer input-string :junk-allowed t
10
:start start :end separator-position))
11
(fractional-part (parse-integer input-string :junk-allowed t
12
:start (1+ separator-position)))
13
(fractional-length (- (length input-string) (1+ separator-position))))
14
(when (and integer-part fractional-part)
16
(* (if (plusp start) -1 1)
17
(+ integer-part (/ fractional-part (expt 10 fractional-length))))))
20
#+sbcl (sb-kernel::%make-ratio value 1)