Skip to content

Commit

Permalink
Rename to float-decimal and decimal-float
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Jun 5, 2024
1 parent b1acc93 commit 58c5589
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
8 changes: 4 additions & 4 deletions code/burger-dybvig/implementation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
;;; of numbers that represent the individual digits of the result,
;;; and the scale factor.

(defmethod quaviver:float-digits ((client client-1) x)
(defmethod quaviver:float-decimal ((client client-1) x)
(let* ((v (rational x))
(v- (rational (predecessor x)))
(v+ (rational (successor x)))
Expand Down Expand Up @@ -346,7 +346,7 @@
;;; This is a direct implementation of the second algorithm of the
;;; Burger & Dybvig paper. It is not modeled after their Scheme code,
;;; but reimplements the algorithm they present in Common Lisp.
(defmethod quaviver:float-digits ((client client-2) x)
(defmethod quaviver:float-decimal ((client client-2) x)
(if (zerop x)
(values #(0) -1 (float-sign x))
(multiple-value-bind (f e sign)
Expand Down Expand Up @@ -428,9 +428,9 @@
(cl:format *trace-output* "~s~%" x)
(finish-output *trace-output*))
do (multiple-value-bind (d1 k1)
(quaviver:float-digits client-1 x)
(quaviver:float-decimal client-1 x)
(multiple-value-bind (d2 k2)
(quaviver:float-digits client-2 x)
(quaviver:float-decimal client-2 x)
(when (not (and (equal d1 (coerce d2 'list))
(= k1 k2)))
(cl:format *trace-output* "no: ~s~%" x))))))
3 changes: 0 additions & 3 deletions code/ieee754.lisp → code/ieee754/implementation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
;;;;
;;;; [1]: https://github.com/sharplispers/nibbles

(cl:defpackage #:quaviver/ieee754
(:use #:common-lisp)
(:export #:client))
(cl:in-package #:quaviver/ieee754)

(defclass client () ())
Expand Down
13 changes: 13 additions & 0 deletions code/ieee754/packages.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;;;; SPDX-FileCopyrightText: Copyright (c) 2024 s-expressionists
;;;; SPDX-License-Identifier: MIT AND BSD-3-Clause
;;;;
;;;; The implementations of QUAVIVER:BITS-FLOAT and QUAVIVER:FLOAT-BITS
;;;; were ported, with modifications, from Nibbles [1], which is
;;;; licensed under the BSD-3-Clause license.
;;;; Any original code herein is licensed under the MIT license (Expat).
;;;;
;;;; [1]: https://github.com/sharplispers/nibbles

(cl:defpackage #:quaviver/ieee754
(:use #:common-lisp)
(:export #:client))
4 changes: 2 additions & 2 deletions code/interface.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

(defgeneric float-bits (client value))

(defgeneric digits-float (client result-type digits exponent sign))
(defgeneric decimal-float (client result-type digits exponent sign))

(defgeneric float-digits (client value))
(defgeneric float-decimal (client value))
5 changes: 2 additions & 3 deletions code/packages.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(defpackage #:quaviver
(:use #:common-lisp)
(:shadow #:float-digits)
(:export #:bits-float
#:float-bits
#:digits-float
#:float-digits))
#:decimal-float
#:float-decimal))
5 changes: 4 additions & 1 deletion quaviver.asd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
:source-control (:git "https://github.com/s-expressionists/Quaviver.git")
:depends-on ("quaviver")
:components ((:module "code"
:components ((:file "ieee754")))))
:pathname "code/ieee754/"
:serial t
:components ((:file "packages")
(:file "implementation")))))

(defsystem "quaviver/burger-dybvig"
:description "Burger Dybvig algorithm for Quaviver"
Expand Down

0 comments on commit 58c5589

Please sign in to comment.