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:27:55 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

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

Yes, there are specializations of init for float and double. They are in
Range.cc and they handle NaN values etc:


  template <>
  void
  range<double>::init (void)
  {
    return xinit (m_base, m_limit, m_increment, m_final, m_numel);
  }

  template <>
  void
  range<float>::init (void)
  {
    return xinit (m_base, m_limit, m_increment, m_final, m_numel);
  }


Not sure of the consequences yet of casting to int64_t or not casting. So far,
make check performs correctly, so no regressions at least. Here is a version
that avoids numer and denom entirely:


    void init (void)
    {
      m_numel = ((m_increment == T (0)
                  || (m_limit > m_base && m_increment < T (0))
                  || (m_limit < m_base && m_increment > T (0)))
                 ? 0
                 : (m_limit.value () - m_base.value () + m_increment.value
())
                   / m_increment.value ());

      m_final = m_base + (m_numel - 1) * m_increment;
    }


But now I have no idea what the conversion is going to be from foo.value() to
octave_idx_type -- is that a safe conversion internally?


    _______________________________________________________

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]