unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#30953: ‘min’ and ‘max’ behavior when mixing exact and inexact numbers.
@ 2018-03-26 14:11 Mathieu Lirzin
  2018-03-27  2:21 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Lirzin @ 2018-03-26 14:11 UTC (permalink / raw)
  To: 30953

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-27  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 14:11 bug#30953: ‘min’ and ‘max’ behavior when mixing exact and inexact numbers Mathieu Lirzin
2018-03-27  2:21 ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).