The following patch makes equality in DFLOAT conform to the IEEE 754
standard concerning equality:

"According to the IEEE 754 standard, negative zero and positive zero
should compare as equal with the usual (numerical) comparison
operators, like the == operators of C and Java. "

https://github.com/billpage/fricas/commit/cfd3150613557acfb5a7986c6561b3ee84f09727
https://github.com/billpage/fricas/commit/cfd3150613557acfb5a7986c6561b3ee84f09727.patch
--
>From cfd3150613557acfb5a7986c6561b3ee84f09727 Mon Sep 17 00:00:00 2001
From: Bill Page <bill.p...@newsynthesis.org>
Date: Sun, 16 Sep 2018 14:57:29 -0400
Subject: [PATCH] Use EQUALP for =

---
 src/lisp/primitives.lisp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lisp/primitives.lisp b/src/lisp/primitives.lisp
index 1b3017e4..7aed05df 100644
--- a/src/lisp/primitives.lisp
+++ b/src/lisp/primitives.lisp
@@ -284,7 +284,8 @@
 (progn
 (defmacro |less_DF| (x y) `(< (the double-float ,x)
                                              (the double-float ,y)))
-(defmacro |eql_DF| (x y) `(EQL (the double-float ,x)
+;; use EQUALP (or maybe just = ??) to be consistent with zero?_DF
+(defmacro |eql_DF| (x y) `(EQUALP (the double-float ,x)
                                              (the double-float ,y)))
 (defmacro |expt_DF_I| (x y) `(EXPT (the double-float ,x)
                                  (the integer ,y)))
--

This fixes the problem reported by Konrad. 'norm-out' does not find
any regressions.


On Sat, Sep 15, 2018 at 1:30 PM Bill Page <bill.p...@newsynthesis.org> wrote:
>
> Konrad Schrempf reports the following bug:
>
> (1) -> A := matrix([[0]])$Matrix(DFLOAT)
>
>    (1)  [0.0]
>                                                     Type: Matrix(DoubleFloat)
> (2) -> rowEchelon(A)
>
>    (2)  [0.0]
>                                                     Type: Matrix(DoubleFloat)
> (3) -> A := matrix([[-0$DFLOAT]])
>
>    (3)  [-0.0]
>                                                     Type: Matrix(DoubleFloat)
>
> (4) -> rowEchelon(A)
>
>    >> Error detected within library code:
>    not invertible
>
> (5) -> zero?(-0$DFLOAT)
>
>    (5)  true
>                                                                 Type: Boolean
> (6) -> zero?(0$DFLOAT)
>
>    (6)  true
>                                                                 Type: Boolean
> (7) -> (-0$DFLOAT ~= 0$DFLOAT)@Boolean
>
>    (7)  true

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to