gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 07/07: value-parser: Distinguish -0 from +0 as floating


From: gnunet
Subject: [gnunet-scheme] 07/07: value-parser: Distinguish -0 from +0 as floating point number.
Date: Sun, 28 Aug 2022 22:03:13 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit 1b75c50a7baa1c13df02dc3bd9b49039923c3805
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sun Aug 28 22:01:55 2022 +0200

    value-parser: Distinguish -0 from +0 as floating point number.
    
    * gnu/gnunet/config/value-parser.scm
    (value->float): When text is "-0", return -0.0.
    * tests/config-value-parser.scm
    ("value->float, negative 0 (d)"): Expect success.
---
 gnu/gnunet/config/value-parser.scm | 6 +++++-
 tests/config-value-parser.scm      | 1 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gnu/gnunet/config/value-parser.scm 
b/gnu/gnunet/config/value-parser.scm
index 65bf994..7cf4ce0 100644
--- a/gnu/gnunet/config/value-parser.scm
+++ b/gnu/gnunet/config/value-parser.scm
@@ -106,7 +106,11 @@ In case of a parse error, raise an appropriate
 In case of a parse error, raise an appropriate
 @code{&value-parse/float-error}."
       (if (regexp-exec float-regex text)
-         (exact->inexact (string->number text))
+         (if (string=? text "-0")
+             ;; The code below would return +0.0 instead,
+             ;; even though -0.0 is separate from +0.0 on IEEE.
+             -0.0
+             (exact->inexact (string->number text)))
          (raise (make-value-parse/float-error text))))
 
     (define (value->boolean text)
diff --git a/tests/config-value-parser.scm b/tests/config-value-parser.scm
index 6f272b3..f8953d9 100644
--- a/tests/config-value-parser.scm
+++ b/tests/config-value-parser.scm
@@ -121,7 +121,6 @@
 (test-eqv "value->float, negative 0 (c)"
   -0.0
   (value->float "-.0"))
-(test-expect-fail 1)
 (test-eqv "value->float, negative 0 (d)"
   -0.0
   (value->float "-0"))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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