octave-maintainers
[Top][All Lists]
Advanced

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

Re: New randi function added


From: Jordi Gutiérrez Hermoso
Subject: Re: New randi function added
Date: Sun, 15 Aug 2010 18:18:20 -0500

On 15 August 2010 17:04, Rik <address@hidden> wrote:
> During the coding I came across a need to know the largest integer that
> would fit within a given data class.  This was easy for the integer classes
> (intmax("CLASS")) and for doubles there is bitmax().  Is there equivalent
> functionality for singles?

Why not wrap C++'s <limits> header?

     #include <iostream>
     #include <limits>

     using namespace std;

     int main()
     {
       cout << "Max float: " << numeric_limits<float>::max() << endl;
     }

You can use is_iec559 if you want to ensure that float is 4 bytes,
although I can't imagine that anyone would be using a non-IEEE754
implementation of C++ for compiling Octave. I would expect that there
are already several assumptions in Octave sources that
numeric_limits<float>::is_iec559 is true.

- Jordi G. H.



reply via email to

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