9 #define REAL_LONG_DOUBLE 2
10 #define REAL_SINGLE_FAST2SUM 3 //TODO: Remove, is FITH
11 #define REAL_RATIONAL 4
12 #define REAL_RATIONAL_ARBINT 5
15 #error "REAL was not defined!"
18 #if REAL >= REAL_SINGLE_FAST2SUM
19 #include "real_fast2sum.h"
22 #if REAL == REAL_RATIONAL
26 #if REAL == REAL_RATIONAL_ARBINT
33 extern const char * g_real_name[];
35 #if REAL == REAL_SINGLE
37 #elif REAL == REAL_DOUBLE
39 #elif REAL == REAL_LONG_DOUBLE
40 typedef long double Real;
41 #elif REAL == REAL_SINGLE_FAST2SUM
42 typedef RealF2S<float> Real;
43 inline float Float(const Real & r) {return r.m_value;}
44 inline double Double(const Real & r) {return r.m_value;}
45 #elif REAL == REAL_RATIONAL
47 typedef Rational<int64_t> Real;
48 inline float Float(const Real & r) {return (float)r.ToDouble();}
49 inline double Double(const Real & r) {return r.ToDouble();}
50 #elif REAL == REAL_RATIONAL_ARBINT
51 typedef Rational<Arbint> Real;
52 inline float Float(const Real & r) {return (float)r.ToDouble();}
53 inline double Double(const Real & r) {return r.ToDouble();}
54 inline Rational<Arbint> pow(const Rational<Arbint> & a, const Rational<Arbint> & b)
56 Arbint P(std::pow(static_cast<double>(a.P), b.ToDouble()));
57 Arbint Q(std::pow(static_cast<double>(a.Q), b.ToDouble()));
58 return Rational<Arbint>(P,Q);
61 #error "Type of Real unspecified."
64 // Allow us to call Float on the primative types
65 // Useful so I can template some things that could be either (a more complicated) Real or a primitive type
66 // Mostly in the testers.
67 inline float Float(float f) {return (float)f;}
68 inline float Float(double f) {return (float)f;}
69 inline float Float(long double f) {return (float)(f);}
70 inline double Double(float f) {return (double)f;}
71 inline double Double(double f) {return (double)f;}
72 inline double Double(long double f) {return (double)(f);}