emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master d56dd03: Improve single precision floating point serialisa


From: Mario Lang
Subject: [elpa] master d56dd03: Improve single precision floating point serialisation
Date: Wed, 18 Dec 2019 03:59:38 -0500 (EST)

branch: master
commit d56dd0378c5f8a582066c636599be1f297691142
Author: Mario Lang <address@hidden>
Commit: Mario Lang <address@hidden>

    Improve single precision floating point serialisation
    
    * packages/osc/osc.el: Update copyright years and author email.
    * (osc-insert-float32): Use `copysign' and `isnan'.
---
 packages/osc/osc.el | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/packages/osc/osc.el b/packages/osc/osc.el
index 9f92b17..316b532 100644
--- a/packages/osc/osc.el
+++ b/packages/osc/osc.el
@@ -1,8 +1,8 @@
 ;;; osc.el --- Open Sound Control protocol library
 
-;; Copyright (C) 2014  Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019  Free Software Foundation, Inc.
 
-;; Author: Mario Lang <address@hidden>
+;; Author: Mario Lang <address@hidden>
 ;; Version: 0.1
 ;; Keywords: comm, processes, multimedia
 
@@ -57,15 +57,13 @@
 (defun osc-insert-float32 (value)
   (let (s (e 0) f)
     (cond
-     ((string= (format "%f" value) (format "%f" -0.0))
-      (setq s 1 f 0))
-     ((string= (format "%f" value) (format "%f" 0.0))
-      (setq s 0 f 0))
+     ((= value 0.0)
+      (setq s (if (< (copysign 1.0 value) 0) 1 0) f 0))
      ((= value 1.0e+INF)
       (setq s 0 e 255 f (1- (expt 2 23))))
      ((= value -1.0e+INF)
       (setq s 1 e 255 f (1- (expt 2 23))))
-     ((string= (format "%f" value) (format "%f" 0.0e+NaN))
+     ((isnan value)
       (setq s 0 e 255 f 1))
      (t
       (setq s (if (>= value 0.0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]