GNU bug report logs - #69725
Incorrect comapration between exact and inexact numbers

Previous Next

Package: guile;

Reported by: Maciej <m.kalandyk <at> outlook.com>

Date: Mon, 11 Mar 2024 07:53:02 UTC

Severity: normal

Done: lloda <lloda <at> sarc.name>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69725 in the body.
You can then email your comments to 69725 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#69725; Package guile. (Mon, 11 Mar 2024 07:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maciej <m.kalandyk <at> outlook.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Mon, 11 Mar 2024 07:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maciej <m.kalandyk <at> outlook.com>
To: bug-guile <at> gnu.org
Subject: Incorrect comapration between exact and inexact numbers
Date: Mon, 11 Mar 2024 08:46:16 +0100
description:

script(named main.scm):
(use-modules (srfi srfi-11))

(define* (newton-sqrt x #:optional (tolerance 0.001) (guess 1))
  (if (< (abs (- x (* guess guess)))
	 tolerance)
      (values guess (abs (- x (* guess guess))) tolerance)
      (newton-sqrt x tolerance (/ (+ guess (/ x guess)) 2))))

(let-values ([(root diff tolerance)
	      (newton-sqrt 1000)])
  (display (exact->inexact diff)) ;; 1.217168231948292
  (newline)
  (display tolerance) ;; 0.001
  (newline)
  ;; bug here 1.217 in exact form apparently is smaller than 0.001
  (display (< diff tolerance)) ;; #t
  (newline)
  (display (< diff (inexact->exact tolerance))) ;; #f
  (newline)
  (display (< (exact->inexact diff) tolerance)) ;; #f
  (newline))

guile version:
guile --version
guile (GNU Guile) 3.0.9

machine-type:
./config.guess
x86_64-pc-linux-gnu

system package:
guix package -V guile
guix package (GNU Guix) f18d13b5f89c161c6ee88d15ecdaa8d973ee4503

additional system info:
guix channels.scm
(list (channel
        (name 'guix)
        (url "https://git.savannah.gnu.org/git/guix.git")
        (branch "master")
        (commit
          "aeb494322ca9dec4a4d66a7d063239c8536bd538")
        (introduction
          (make-channel-introduction
            "9edb3f66fd807b096b48283debdcddccfea34bad"
            (openpgp-fingerprint
              "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))

what i ran to run the script:
guix time-machine -C channels.scm -- shell --pure guile -- ./main.scm
1.217168231948292
0.001
#t
#f
#f




Information forwarded to bug-guile <at> gnu.org:
bug#69725; Package guile. (Mon, 18 Mar 2024 16:18:02 GMT) Full text and rfc822 format available.

Message #8 received at 69725 <at> debbugs.gnu.org (full text, mbox):

From: lloda <lloda <at> sarc.name>
To: Maciej <m.kalandyk <at> outlook.com>
Cc: 69725 <at> debbugs.gnu.org
Subject: Re: bug#69725: Incorrect comapration between exact and inexact numbers
Date: Mon, 18 Mar 2024 17:17:02 +0100
[Message part 1 (text/plain, inline)]
Thanks for the report! Patch attached.

regards

  Daniel


[0001-Add-missing-branch-in-scm_is_less_than.patch (application/octet-stream, attachment)]

Reply sent to lloda <lloda <at> sarc.name>:
You have taken responsibility. (Tue, 19 Mar 2024 17:31:02 GMT) Full text and rfc822 format available.

Notification sent to Maciej <m.kalandyk <at> outlook.com>:
bug acknowledged by developer. (Tue, 19 Mar 2024 17:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 69725-done <at> debbugs.gnu.org (full text, mbox):

From: lloda <lloda <at> sarc.name>
To: Maciej <m.kalandyk <at> outlook.com>
Cc: 69725-done <at> debbugs.gnu.org
Subject: Re: bug#69725: Incorrect comapration between exact and inexact numbers
Date: Tue, 19 Mar 2024 18:29:48 +0100
Patch committed to 54c4753dd3f7506bee2778b36d7263b613ffd579, with a couple extra tests.

Thanks

	Daniel





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Apr 2024 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.