]> www.ginac.de Git - cln.git/blob - src/base/cl_N.h
d94606234801f305fb7863e3a553b5cb084609b1
[cln.git] / src / base / cl_N.h
1 // cl_N internals
2
3 #ifndef _CL_N_H
4 #define _CL_N_H
5
6 #include "cln/number.h"
7 #include "base/cl_macros.h"
8
9 namespace cln {
10
11 // For the equal-invariant hashcode, we take a mixture of exponent, length
12 // and the most significant 32 bits. To ensure that equal(x,y) implies
13 // equal_hashcode(x) == equal_hashcode(y) we must make sure that
14 // equal_hashcode(rational(x)) == equal_hashcode(x) and
15 // equal_hashcode(0.0) = 0 (important because of equal(complex(x,0.0),x)).
16   #define equal_hashcode_low(msd,exp,sign)  \
17     (((((uint32)(msd) << 7) | ((uint32)(msd) >> 25)) ^ ((sint32)(sign) << 30)) + (uintL)(exp))
18   #define equal_hashcode_one  equal_hashcode_low(bit(31),1,0)
19
20 }  // namespace cln
21
22 #endif /* _CL_N_H */