octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #61290] Unexpected rounding of min and max wit


From: anonymous
Subject: [Octave-bug-tracker] [bug #61290] Unexpected rounding of min and max with integer types
Date: Tue, 5 Oct 2021 12:26:46 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

URL:
  <https://savannah.gnu.org/bugs/?61290>

                 Summary: Unexpected rounding of min and max with integer
types
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Tue 05 Oct 2021 04:26:44 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error or Warning
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 6.3.0
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

Integer types cause implicit and unexpected rounding when used with min and
max. Is this intended behavior or is it a bug?


>> n = uint8 (240), min (n, sqrt(n))
n = 240
ans = 15            ## sqrt(240) gets rounded DOWN to 15

>> n = uint8 (241), min (n, sqrt(n))
n = 241
ans = 16            ## sqrt(241) gets rounded UP to 16


There is nothing in the documentation for min and max about the rules when one
operand is an integer and the other is a floating point. If the above behavior
is not a bug, should it be documented?

Current workarounds: explicitly call floor() and ceil() as required, or cast n
to double before calling min or max.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61290>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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