[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.5 Comparisons
Each of the classes cl_N
, cl_R
, cl_RA
, cl_I
,
cl_F
, cl_SF
, cl_FF
, cl_DF
, cl_LF
defines the following operations:
bool operator == (const type&, const type&)
bool operator != (const type&, const type&)
-
Comparison, as in C and C++.
uint32 equal_hashcode (const type&)
-
Returns a 32-bit hash code that is the same for any two numbers which are the same according to
==
. This hash code depends on the number’s value, not its type or precision. bool zerop (const type& x)
-
Compare against zero:
x == 0
Each of the classes cl_R
, cl_RA
, cl_I
,
cl_F
, cl_SF
, cl_FF
, cl_DF
, cl_LF
defines the following operations:
cl_signean compare (const type& x, const type& y)
-
Compares
x
andy
. Returns +1 ifx
>y
, -1 ifx
<y
, 0 ifx
=y
. bool operator <= (const type&, const type&)
bool operator < (const type&, const type&)
bool operator >= (const type&, const type&)
bool operator > (const type&, const type&)
-
Comparison, as in C and C++.
bool minusp (const type& x)
-
Compare against zero:
x < 0
bool plusp (const type& x)
-
Compare against zero:
x > 0
type max (const type& x, const type& y)
-
Return the maximum of
x
andy
. type min (const type& x, const type& y)
-
Return the minimum of
x
andy
.
When a floating point number and a rational number are compared, the float
is first converted to a rational number using the function rational
.
Since a floating point number actually represents an interval of real numbers,
the result might be surprising.
For example, (cl_F)(cl_R)"1/3" == (cl_R)"1/3"
returns false because
there is no floating point number whose value is exactly 1/3
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 27, 2013 using texi2html 5.0.