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

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

[Octave-bug-tracker] [bug #61300] integer range might exceed upper limit


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #61300] integer range might exceed upper limit
Date: Sun, 28 Nov 2021 14:04:02 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Follow-up Comment #18, bug #61300 (project octave):

Since we no longer need floor() for the calculation, I removed cmath from the
included header files. Updated patch attached. Please verify.


diff -r 3c4639e42855 liboctave/array/Range.h
--- a/liboctave/array/Range.h   Fri Nov 26 16:22:19 2021 -0800
+++ b/liboctave/array/Range.h   Sun Nov 28 14:01:47 2021 -0500
@@ -322,11 +322,14 @@
 
     void init (void)
     {
+      int64_t numer = m_limit.value () - m_base.value () + m_increment.value
();
+      int64_t denom = m_increment.value ();
+
       m_numel = ((m_increment == T (0)
                   || (m_limit > m_base && m_increment < T (0))
                   || (m_limit < m_base && m_increment > T (0)))
-                 ? T (0)
-                 : (m_limit - m_base + m_increment) / m_increment);
+                 ? 0
+                 : (numer / denom));
 
       m_final = m_base + (m_numel - 1) * m_increment;
     }



(file #52363)
    _______________________________________________________

Additional Item Attachment:

File name: range_patch3.patch             Size:0 KB
    <https://file.savannah.gnu.org/file/range_patch3.patch?file_id=52363>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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