9 #define REAL_LONG_DOUBLE 2
11 #define REAL_RATIONAL 4
12 #define REAL_RATIONAL_ARBINT 5
15 #error "REAL was not defined!"
22 #if REAL == REAL_RATIONAL
26 #if REAL == REAL_RATIONAL_ARBINT
34 extern const char * g_real_name[];
36 #if REAL == REAL_SINGLE
38 #elif REAL == REAL_DOUBLE
40 #elif REAL == REAL_LONG_DOUBLE
41 typedef long double Real;
42 #elif REAL == REAL_VFPU
43 typedef VFPU::Float Real;
44 inline float Float(const Real & r) {return r.m_value;}
45 inline double Double(const Real & r) {return r.m_value;}
46 #elif REAL == REAL_RATIONAL
48 typedef Rational<int64_t> Real;
49 inline float Float(const Real & r) {return (float)r.ToDouble();}
50 inline double Double(const Real & r) {return r.ToDouble();}
51 #elif REAL == REAL_RATIONAL_ARBINT
52 #define ARBINT Gmpint // Set to Gmpint or Arbint here
54 typedef Rational<ARBINT> Real;
55 inline float Float(const Real & r) {return (float)r.ToDouble();}
56 inline double Double(const Real & r) {return r.ToDouble();}
59 #error "Type of Real unspecified."
62 // Allow us to call Float on the primative types
63 // Useful so I can template some things that could be either (a more complicated) Real or a primitive type
64 // Mostly in the testers.
65 inline float Float(float f) {return (float)f;}
66 inline float Float(double f) {return (float)f;}
67 inline float Float(long double f) {return (float)(f);}
68 inline double Double(float f) {return (double)f;}
69 inline double Double(double f) {return (double)f;}
70 inline double Double(long double f) {return (double)(f);}
72 inline Real Power(const Real & a, int n)
76 return Power(Real(1)/a, -n);
79 for (int i = 0; i < n; ++i)