GNU bug report logs -
#30953
‘min’ and ‘max’ behavior when mixing exact and inexact numbers.
Previous Next
Reported by: Mathieu Lirzin <mthl <at> gnu.org>
Date: Mon, 26 Mar 2018 14:12:02 UTC
Severity: normal
Tags: notabug
Done: Mark H Weaver <mhw <at> netris.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
I am observing a unexpected behavior of ‘min’ and ‘max’:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (min 1 2.4)
$2 = 1.0
scheme@(guile-user)> (min 1/2 4.0)
$7 = 0.5
scheme@(guile-user)> (max 4 3.5)
$4 = 4.0
--8<---------------cut here---------------end--------------->8---
I would expect the results to be integers instead. AIUI the
implementation of the ‘min’ procedure should to be equivalent to:
(define (min val . rest)
(let loop ((x val) (other rest))
(match other
(() x)
((y . rest) (loop (if (< x y) x y) rest)))))
Maybe there is a good performance reason for the current behavior. If
that's the case then it should be specified in the manual that exact
numbers are converted to real numbers when at least one of the arguments
is inexact.
Thanks.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
This bug report was last modified 7 years and 140 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.