-rw-r--r-- | noncore/unsupported/qpdf/fixed.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/fixed.h b/noncore/unsupported/qpdf/fixed.h index ec0e696..44aaa5e 100644 --- a/noncore/unsupported/qpdf/fixed.h +++ b/noncore/unsupported/qpdf/fixed.h | |||
@@ -1,67 +1,68 @@ | |||
1 | #ifndef __FIXED_H__ | 1 | #ifndef __FIXED_H__ |
2 | #define __FIXED_H__ | 2 | #define __FIXED_H__ |
3 | 3 | ||
4 | #include <stdlib.h> | ||
4 | #include <iostream> | 5 | #include <iostream> |
5 | 6 | ||
6 | #define _GCC_TEMPLATE_BUG_ 1 | 7 | #define _GCC_TEMPLATE_BUG_ 1 |
7 | 8 | ||
8 | template <unsigned int SH> class fixed { | 9 | template <unsigned int SH> class fixed { |
9 | public: | 10 | public: |
10 | inline fixed ( int i = 0 ) : m_f ( i2f( i ) ) { } | 11 | inline fixed ( int i = 0 ) : m_f ( i2f( i ) ) { } |
11 | inline fixed ( double d ) : m_f ( d2f( d )) { } | 12 | inline fixed ( double d ) : m_f ( d2f( d )) { } |
12 | inline fixed ( const fixed &f ) : m_f ( f. m_f ) { } | 13 | inline fixed ( const fixed &f ) : m_f ( f. m_f ) { } |
13 | 14 | ||
14 | inline operator bool ( ) const { return m_f != 0; } | 15 | inline operator bool ( ) const { return m_f != 0; } |
15 | inline operator double ( ) const { return f2d( m_f ); } | 16 | inline operator double ( ) const { return f2d( m_f ); } |
16 | inline operator float ( ) const { return (float) f2d( m_f ); } | 17 | inline operator float ( ) const { return (float) f2d( m_f ); } |
17 | inline operator int ( ) const { return (int) f2i( m_f ); } | 18 | inline operator int ( ) const { return (int) f2i( m_f ); } |
18 | 19 | ||
19 | inline fixed &operator = ( const fixed &f ) { m_f = f. m_f; return *this; } | 20 | inline fixed &operator = ( const fixed &f ) { m_f = f. m_f; return *this; } |
20 | inline fixed &operator = ( double d ) { m_f = d2f( d ); return *this; } | 21 | inline fixed &operator = ( double d ) { m_f = d2f( d ); return *this; } |
21 | inline fixed &operator = ( float f ) { m_f = d2f( f ); return *this; } | 22 | inline fixed &operator = ( float f ) { m_f = d2f( f ); return *this; } |
22 | inline fixed &operator = ( int i ) { m_f = i2f( i ); return *this; } | 23 | inline fixed &operator = ( int i ) { m_f = i2f( i ); return *this; } |
23 | 24 | ||
24 | inline fixed &operator += ( const fixed &f ) { m_f += f. m_f; return *this; } | 25 | inline fixed &operator += ( const fixed &f ) { m_f += f. m_f; return *this; } |
25 | inline fixed &operator -= ( const fixed &f ) { m_f -= f. m_f; return *this; } | 26 | inline fixed &operator -= ( const fixed &f ) { m_f -= f. m_f; return *this; } |
26 | inline fixed &operator *= ( const fixed &f ) { m_f = mul ( m_f, f. m_f ); return *this; } | 27 | inline fixed &operator *= ( const fixed &f ) { m_f = mul ( m_f, f. m_f ); return *this; } |
27 | inline fixed &operator /= ( const fixed &f ) { m_f = div ( m_f, f. m_f ); return *this; } | 28 | inline fixed &operator /= ( const fixed &f ) { m_f = div ( m_f, f. m_f ); return *this; } |
28 | 29 | ||
29 | inline fixed &operator += ( int i ) { m_f += i2f( i ); return *this; } | 30 | inline fixed &operator += ( int i ) { m_f += i2f( i ); return *this; } |
30 | inline fixed &operator -= ( int i ) { m_f -= i2f( i ); return *this; } | 31 | inline fixed &operator -= ( int i ) { m_f -= i2f( i ); return *this; } |
31 | inline fixed &operator *= ( int i ) { m_f *= i; return *this; } | 32 | inline fixed &operator *= ( int i ) { m_f *= i; return *this; } |
32 | inline fixed &operator /= ( int i ) { m_f /= i; return *this; } | 33 | inline fixed &operator /= ( int i ) { m_f /= i; return *this; } |
33 | 34 | ||
34 | inline fixed &operator += ( double d ) { m_f += d2f( d ); return *this; } | 35 | inline fixed &operator += ( double d ) { m_f += d2f( d ); return *this; } |
35 | inline fixed &operator -= ( double d ) { m_f -= d2f( d ); return *this; } | 36 | inline fixed &operator -= ( double d ) { m_f -= d2f( d ); return *this; } |
36 | inline fixed &operator *= ( double d ) { m_f = mul ( m_f, d2f( d )); return *this; } | 37 | inline fixed &operator *= ( double d ) { m_f = mul ( m_f, d2f( d )); return *this; } |
37 | inline fixed &operator /= ( double d ) { m_f = div ( m_f, d2f( d )); return *this; } | 38 | inline fixed &operator /= ( double d ) { m_f = div ( m_f, d2f( d )); return *this; } |
38 | 39 | ||
39 | inline fixed operator - ( ) const { return fixed ( -m_f, true ); } | 40 | inline fixed operator - ( ) const { return fixed ( -m_f, true ); } |
40 | 41 | ||
41 | inline fixed operator + ( const fixed &f ) const { return fixed ( m_f + f. m_f, true ); } | 42 | inline fixed operator + ( const fixed &f ) const { return fixed ( m_f + f. m_f, true ); } |
42 | inline fixed operator - ( const fixed &f ) const { return fixed ( m_f - f. m_f, true ); } | 43 | inline fixed operator - ( const fixed &f ) const { return fixed ( m_f - f. m_f, true ); } |
43 | inline fixed operator * ( const fixed &f ) const { return fixed ( mul ( m_f, f. m_f ), true ); } | 44 | inline fixed operator * ( const fixed &f ) const { return fixed ( mul ( m_f, f. m_f ), true ); } |
44 | inline fixed operator / ( const fixed &f ) const { return fixed ( div ( m_f, f. m_f ), true ); } | 45 | inline fixed operator / ( const fixed &f ) const { return fixed ( div ( m_f, f. m_f ), true ); } |
45 | 46 | ||
46 | inline fixed operator + ( double d ) const { return fixed ( m_f + d2f( d ), true ); } | 47 | inline fixed operator + ( double d ) const { return fixed ( m_f + d2f( d ), true ); } |
47 | inline fixed operator - ( double d ) const { return fixed ( m_f - d2f( d ), true ); } | 48 | inline fixed operator - ( double d ) const { return fixed ( m_f - d2f( d ), true ); } |
48 | inline fixed operator * ( double d ) const { return fixed ( mul ( m_f, d2f( d )), true ); } | 49 | inline fixed operator * ( double d ) const { return fixed ( mul ( m_f, d2f( d )), true ); } |
49 | inline fixed operator / ( double d ) const { return fixed ( div ( m_f, d2f( d )), true ); } | 50 | inline fixed operator / ( double d ) const { return fixed ( div ( m_f, d2f( d )), true ); } |
50 | 51 | ||
51 | inline fixed operator + ( int i ) const { return fixed ( m_f + i2f( i ), true ); } | 52 | inline fixed operator + ( int i ) const { return fixed ( m_f + i2f( i ), true ); } |
52 | inline fixed operator - ( int i ) const { return fixed ( m_f - i2f( i ), true ); } | 53 | inline fixed operator - ( int i ) const { return fixed ( m_f - i2f( i ), true ); } |
53 | inline fixed operator * ( int i ) const { return fixed ( m_f * i, true ); } | 54 | inline fixed operator * ( int i ) const { return fixed ( m_f * i, true ); } |
54 | inline fixed operator / ( int i ) const { return fixed ( m_f / i, true ); } | 55 | inline fixed operator / ( int i ) const { return fixed ( m_f / i, true ); } |
55 | 56 | ||
56 | inline bool operator < ( const fixed &f ) const { return m_f < f. m_f; } | 57 | inline bool operator < ( const fixed &f ) const { return m_f < f. m_f; } |
57 | inline bool operator > ( const fixed &f ) const { return m_f > f. m_f; } | 58 | inline bool operator > ( const fixed &f ) const { return m_f > f. m_f; } |
58 | inline bool operator <= ( const fixed &f ) const { return m_f <= f. m_f; } | 59 | inline bool operator <= ( const fixed &f ) const { return m_f <= f. m_f; } |
59 | inline bool operator >= ( const fixed &f ) const { return m_f >= f. m_f; } | 60 | inline bool operator >= ( const fixed &f ) const { return m_f >= f. m_f; } |
60 | inline bool operator == ( const fixed &f ) const { return m_f == f. m_f; } | 61 | inline bool operator == ( const fixed &f ) const { return m_f == f. m_f; } |
61 | inline bool operator != ( const fixed &f ) const { return m_f != f. m_f; } | 62 | inline bool operator != ( const fixed &f ) const { return m_f != f. m_f; } |
62 | 63 | ||
63 | inline bool operator < ( double d ) const { return m_f < d2f( d ); } | 64 | inline bool operator < ( double d ) const { return m_f < d2f( d ); } |
64 | inline bool operator > ( double d ) const { return m_f > d2f( d ); } | 65 | inline bool operator > ( double d ) const { return m_f > d2f( d ); } |
65 | inline bool operator <= ( double d ) const { return m_f <= d2f( d ); } | 66 | inline bool operator <= ( double d ) const { return m_f <= d2f( d ); } |
66 | inline bool operator >= ( double d ) const { return m_f >= d2f( d ); } | 67 | inline bool operator >= ( double d ) const { return m_f >= d2f( d ); } |
67 | inline bool operator == ( double d ) const { return m_f == d2f( d ); } | 68 | inline bool operator == ( double d ) const { return m_f == d2f( d ); } |