]> www.ginac.de Git - cln.git/blob - src/rational/misc/cl_RA_eqhashcode.cc
* Version 1.1.9 released.
[cln.git] / src / rational / misc / cl_RA_eqhashcode.cc
1 // cl_RA equal_hashcode().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/rational.h"
8
9
10 // Implementation.
11
12 #include "cl_N.h"
13 #include "cl_RA.h"
14
15 namespace cln {
16
17 uint32 equal_hashcode (const cl_RA& r)
18 {
19         if (integerp(r)) {
20                 DeclareType(cl_I,r);
21                 return equal_hashcode(r);
22         } else {
23                 // Making sure that a float and its rational equivalent have
24                 // the same hash code is tricky. This code depends on the fact
25                 // that the equal_hashcode_low macro is linear in `exp'.
26                 DeclareType(cl_RT,r);
27                 return equal_hashcode(numerator(r))
28                        - equal_hashcode(denominator(r))
29                        + equal_hashcode_one;
30         }
31 }
32
33 }  // namespace cln