summaryrefslogtreecommitdiffstats
path: root/bytenumb.scm
diff options
context:
space:
mode:
authorThomas Bushnell, BSG <tb@debian.org>2007-12-28 16:25:32 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:39 -0800
commitd8ae23691ed6392b7f320f5fa7d4dd78ae52c10e (patch)
treeb20b8bc02e854c4c86d39ee22a0638a8b06e01af /bytenumb.scm
parentedd1ebef3ad774e7cbcc2f5918d555bfb0b44091 (diff)
parent64f037d91e0c9296dcaef9a0ff3eb33b19a2ed34 (diff)
downloadslib-d8ae23691ed6392b7f320f5fa7d4dd78ae52c10e.tar.gz
slib-d8ae23691ed6392b7f320f5fa7d4dd78ae52c10e.zip
Import Debian changes 3a5-1debian/3a5-1
slib (3a5-1) unstable; urgency=low * New upstream release. * slib.texi (Library Catalogs): Repeat change from 3a3-3. * Makefile: Repeat $(htmldir)slib_toc.html changes from 3a2-1. * guile.init: (library-vicinity): Repeat change from 3a4-2. * debian/rules (binary-indep): Don't hide .init files in a separate subdirectory, thus conforming better to the usual slib practice. Put a symlink in place to ease transitions. (Closes: #407370).
Diffstat (limited to 'bytenumb.scm')
-rw-r--r--bytenumb.scm47
1 files changed, 30 insertions, 17 deletions
diff --git a/bytenumb.scm b/bytenumb.scm
index cb9b5c5..053a433 100644
--- a/bytenumb.scm
+++ b/bytenumb.scm
@@ -130,6 +130,7 @@
;;(bytes->ieee-float (bytes #xff #x80 0 0)) @result{} -inf.0
;;(bytes->ieee-float (bytes #x7f #x80 0 0)) @result{} +inf.0
;;(bytes->ieee-float (bytes #x7f #x80 0 1)) @result{} 0/0
+;;(bytes->ieee-float (bytes #x7f #xc0 0 0)) @result{} 0/0
;;@end example
;;@body
@@ -189,12 +190,11 @@
(define S (and (real? flt) (negative? (if (zero? flt) (/ flt) flt))))
(define (scale flt scl)
(cond ((zero? scl) (out (/ flt 2) scl))
- ((zero? flt) (if S (byte-set! byts 0 #x80)) byts)
- ((or (not (real? flt)) (>= flt 16))
+ ((>= flt 16)
(let ((flt/16 (/ flt 16)))
(cond ((= flt/16 flt)
(byte-set! byts 0 (if S #xFF #x7F))
- (byte-set! byts 1 (if (= flt (* zero flt)) #xC0 #x80))
+ (byte-set! byts 1 #x80)
byts)
(else (scale flt/16 (+ scl 4))))))
((>= flt 2) (scale (/ flt 2) (+ scl 1)))
@@ -212,7 +212,14 @@
(byte-set! byts 0 (+ (if S 128 0) (ash scl -1)))
byts)
(byte-set! byts idx val)))
- (scale (abs flt) 127))))
+ (set! flt (magnitude flt))
+ (cond ((zero? flt) (if S (byte-set! byts 0 #x80)) byts)
+ ((or (not (real? flt))
+ (not (= flt flt)))
+ (byte-set! byts 0 (if S #xFF #x7F))
+ (byte-set! byts 1 #xC0)
+ byts)
+ (else (scale flt 127))))))
;;@example
;;(bytes->list (ieee-float->bytes 0.0)) @result{} (0 0 0 0)
;;(bytes->list (ieee-float->bytes -0.0)) @result{} (128 0 0 0)
@@ -226,7 +233,7 @@
;;
;;(bytes->list (ieee-float->bytes -inf.0)) @result{} (255 128 0 0)
;;(bytes->list (ieee-float->bytes +inf.0)) @result{} (127 128 0 0)
-;;(bytes->list (ieee-float->bytes 0/0)) @result{} (127 128 0 1)
+;;(bytes->list (ieee-float->bytes 0/0)) @result{} (127 192 0 0)
;;@end example
@@ -241,12 +248,11 @@
(define S (and (real? flt) (negative? (if (zero? flt) (/ flt) flt))))
(define (scale flt scl)
(cond ((zero? scl) (out (/ flt 2) scl))
- ((zero? flt) (if S (byte-set! byts 0 #x80)) byts)
- ((or (not (real? flt)) (>= flt 16))
+ ((>= flt 16)
(let ((flt/16 (/ flt 16)))
(cond ((= flt/16 flt)
(byte-set! byts 0 (if S #xFF #x7F))
- (byte-set! byts 1 (if (= flt (* zero flt)) #xF8 #xF0))
+ (byte-set! byts 1 #xF0)
byts)
(else (scale flt/16 (+ scl 4))))))
((>= flt 2) (scale (/ flt 2) (+ scl 1)))
@@ -264,7 +270,14 @@
(byte-set! byts 0 (+ (if S 128 0) (ash scl -4)))
byts)
(byte-set! byts idx val)))
- (scale (abs flt) 1023))))
+ (set! flt (magnitude flt))
+ (cond ((zero? flt) (if S (byte-set! byts 0 #x80)) byts)
+ ((or (not (real? flt))
+ (not (= flt flt)))
+ (byte-set! byts 0 #x7F)
+ (byte-set! byts 1 #xF8)
+ byts)
+ (else (scale flt 1023))))))
;;@example
;;(bytes->list (ieee-double->bytes 0.0)) @result{} (0 0 0 0 0 0 0 0)
;;(bytes->list (ieee-double->bytes -0.0)) @result{} (128 0 0 0 0 0 0 0)
@@ -315,7 +328,7 @@
;;@body
;;Modifies @1 so that @code{string<?} ordering of IEEE floating-point
;;byte-vectors matches numerical order. @0 returns @1.
-(define (IEEE-byte-collate! byte-vector)
+(define (ieee-byte-collate! byte-vector)
(cond ((logtest #x80 (byte-ref byte-vector 0))
(do ((idx (+ -1 (bytes-length byte-vector)) (+ -1 idx)))
((negative? idx))
@@ -325,9 +338,9 @@
(byte-set! byte-vector 0 (logxor #x80 (byte-ref byte-vector 0)))))
byte-vector)
;;@body
-;;Given @1 modified by @code{IEEE-byte-collate!}, reverses the @1
+;;Given @1 modified by @code{ieee-byte-collate!}, reverses the @1
;;modifications.
-(define (IEEE-byte-decollate! byte-vector)
+(define (ieee-byte-decollate! byte-vector)
(cond ((not (logtest #x80 (byte-ref byte-vector 0)))
(do ((idx (+ -1 (bytes-length byte-vector)) (+ -1 idx)))
((negative? idx))
@@ -340,10 +353,10 @@
;;@body
;;Returns copy of @1 encoded so that @code{string<?} ordering of IEEE
;;floating-point byte-vectors matches numerical order.
-(define (IEEE-byte-collate byte-vector)
- (IEEE-byte-collate! (bytes-copy byte-vector)))
+(define (ieee-byte-collate byte-vector)
+ (ieee-byte-collate! (bytes-copy byte-vector)))
;;@body
-;;Given @1 returned by @code{IEEE-byte-collate}, reverses the @1
+;;Given @1 returned by @code{ieee-byte-collate}, reverses the @1
;;modifications.
-(define (IEEE-byte-decollate byte-vector)
- (IEEE-byte-decollate! (bytes-copy byte-vector)))
+(define (ieee-byte-decollate byte-vector)
+ (ieee-byte-decollate! (bytes-copy byte-vector)))