[Top][All Lists]

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

bug#30953: ‘min’ and ‘max’ behavior when mixing exact and inexact number

From: Mathieu Lirzin
Subject: bug#30953: ‘min’ and ‘max’ behavior when mixing exact and inexact numbers.
Date: Mon, 26 Mar 2018 16:11:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)


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.


Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

reply via email to

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