Moronic bug identified, also Backtrace is a thing now
[ipdf/code.git] / src / real.h
1 #ifndef _REAL_H
2 #define _REAL_H
3
4 #include "common.h"
5
6
7 #define REAL_SINGLE 0
8 #define REAL_DOUBLE 1
9 #define REAL_LONG_DOUBLE 2
10 #define REAL_SINGLE_FAST2SUM 3 //TODO: Remove, is FITH
11 #define REAL_RATIONAL 4
12
13 #ifndef REAL
14         #error "REAL was not defined!"
15 #endif
16
17 #if REAL >= REAL_SINGLE_FAST2SUM
18         #include "real_fast2sum.h"
19 #endif //REAL
20
21 #if REAL == REAL_RATIONAL
22         #include "rational.h"
23 #endif //REAL
24
25 namespace IPDF
26 {       
27         extern const char * g_real_name[];
28
29 #if REAL == REAL_SINGLE
30         typedef float Real;
31 #elif REAL == REAL_DOUBLE
32         typedef double Real;
33 #elif REAL == REAL_LONG_DOUBLE
34         typedef long double Real;
35 #elif REAL == REAL_SINGLE_FAST2SUM
36         typedef RealF2S<float> Real;
37         inline float Float(const Real & r) {return r.m_value;}
38         inline double Double(const Real & r) {return r.m_value;}
39 #elif REAL == REAL_RATIONAL
40
41         typedef Rational<int64_t> Real;
42         inline float Float(const Real & r) {return (float)r.ToDouble();}
43         inline double Double(const Real & r) {return r.ToDouble();}
44 #else
45         #error "Type of Real unspecified."
46 #endif //REAL
47
48         // Allow us to call Float on the primative types
49         // Useful so I can template some things that could be either (a more complicated) Real or a primitive type
50         // Mostly in the testers.
51         inline float Float(float f) {return (float)f;}
52         inline float Float(double f) {return (float)f;}
53         inline float Float(long double f) {return (float)(f);}
54         inline double Double(float f) {return (double)f;}
55         inline double Double(double f) {return (double)f;}
56         inline double Double(long double f) {return (double)(f);}
57 }
58
59 #endif //_REAL_H

UCC git Repository :: git.ucc.asn.au