/usr/include/sidplay/fixpoint.h is in libsidplay1-dev 1.36.59-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | /*******************************************************************************
*
* File header: PseudoFloat.h
*
* Description: Fixed point class
*
*
* Author: Vincent Penné
*
* Date: Sat 18th October 1997
*
*******************************************************************************/
/***************************************************************/
#ifndef SIDPLAY1_FIXPOINT_H
#define SIDPLAY1_FIXPOINT_H
class fixed {
public:
int v;
inline fixed() {}
inline fixed(const int a, int dummy) { v=a; dummy=dummy; } // basic constructor (ugly !)
inline fixed(const int a) { v=a<<16; }
inline fixed(const unsigned int a) { v=a<<16; }
inline fixed(const long a) { v=a<<16; }
inline fixed(const unsigned long a) { v=a<<16; }
inline fixed(double a) { v=int(a*(1<<16)); }
inline fixed(float a) { v=int(a*(1<<16)); }
// inline fixed make_fixed(int a) { fixed r; r.v=a; return r; }
// inline fixed(fixed &a) { v=a.v; }
inline operator float() { return float(v)/(1<<16); }
inline operator double() { return double(v)/(1<<16); }
// inline &operator fixed() { return make_fixed(a.v); }
// inline fixed(int &a) { v=a<<16; }
// inline fixed(float a) { v=int(a*(1<<16)); }
// inline fixed(double a) { v=int(a*(1<<16)); }
inline operator signed char() { return v>>16; }
inline operator unsigned char() { return v>>16; }
inline operator int() { return v>>16; }
inline operator unsigned int() { return v>>16; }
inline operator long() { return v>>16; }
inline operator unsigned long() { return v>>16; }
inline friend fixed operator - (const fixed &a) { return fixed(-a.v, 0); }
static inline fixed multiply(const fixed &a, const fixed &b) { return fixed((a.v>>8)*(b.v>>8),0); }
static inline fixed divide(const fixed &a, const fixed &b) { return fixed((a.v<<8)/(b.v>>8),0); }
inline fixed operator *(const fixed &b) { return fixed((v>>8)*(b.v>>8),0); }
inline fixed operator /(const fixed &b) { return fixed((v<<8)/(b.v>>8),0); }
inline fixed operator +(const fixed &b) { return fixed(v+b.v,0); }
inline fixed operator -(const fixed &b) { return fixed(v-b.v,0); }
inline fixed& operator +=(const fixed &b) { v+=b.v; return *this; }
inline fixed& operator -=(const fixed &b) { v-=b.v; return *this; }
inline fixed& operator *=(const fixed &b) { v=(v>>8)*(b.v>>8); return *this; }
inline fixed& operator *=(const int b) { v*=b; return *this; }
inline fixed& operator *=(const double b) { *this*=fixed(b); return *this; }
inline fixed& operator *=(const float b) { *this*=fixed(b); return *this; }
inline friend float& operator *=(float &a, fixed &b) { a = a*float(b); return a; }
inline fixed& operator /=(const fixed &b) { v=(v<<8)/(b.v>>8); return *this; }
inline fixed& operator /=(const int b) { v/=b; return *this; }
inline fixed& operator /=(const unsigned int b) { v/=b; return *this; }
inline fixed& operator /=(const double b) { *this/=fixed(b); return *this; }
inline fixed& operator /=(const float b) { *this/=fixed(b); return *this; }
inline bool operator ==(const fixed &b) { return v==b.v; }
inline bool operator !=(const fixed &b) { return v!=b.v; }
inline bool operator !=(const float &b) { return v!=b/(1<<16); }
inline bool operator <(const fixed &b) { return v<b.v; }
inline bool operator <(double b) { return *this<fixed(b); }
inline bool operator >(const fixed &b) { return v>b.v; }
inline bool operator >(const int b) { return v>(b<<16); }
inline bool operator <=(const fixed &b) { return v<=b.v; }
inline bool operator >=(const fixed &b) { return v>=b.v; }
/* friend inline fixed operator * (const double &a, const fixed &b)
{ return make_fixed((a*(1<<16))*b.v); }*/
friend inline fixed operator / (const float a, const fixed &b)
{ return fixed(a)/b; }
friend inline fixed operator / (const double a, const fixed &b)
{ return fixed(a)/b; }
friend inline fixed operator + (const int a, const fixed &b)
{ return fixed((a<<16)+b.v,0); }
friend inline fixed operator + (const double a, const fixed &b)
{ return fixed(int(a*(1<<16))+b.v,0); }
friend inline fixed operator - (const double a, const fixed &b)
{ return fixed(int(a*(1<<16))-b.v,0); }
friend inline fixed operator + (const float a, const fixed &b)
{ return fixed(int(a*(1<<16))+b.v,0); }
friend inline fixed operator - (const float a, const fixed &b)
{ return fixed(int(a*(1<<16))-b.v,0); }
friend inline fixed operator - (const fixed &a, const double b)
{ return fixed(a.v-int(b*(1<<16)),0); }
friend inline fixed operator + (const fixed &a, const float b)
{ return fixed(a.v+int(b*(1<<16)),0); }
friend inline fixed operator / (const int a, const fixed &b)
{ return fixed((a<<24)/(b.v>>8),0); }
friend inline fixed operator / (const fixed &a, const int b)
{ return fixed(a.v/b,0); }
friend inline fixed operator / (const fixed &a, const long int b)
{ return fixed(a.v/b,0); }
friend inline fixed operator * (const int b, const fixed &a)
{ return fixed(a.v*b,0); }
friend inline fixed operator * (const fixed &a, const int b)
{ return fixed(a.v*b,0); }
friend inline fixed operator * (const fixed &a, const long int b)
{ return fixed(a.v*b,0); }
// inline operator float() { return v/(1<<16); }
// inline operator double() { return v/double(1<<16); }
};
inline fixed operator / (const fixed &a, const double b)
{ return fixed::divide(a,fixed(b)); }
inline fixed operator / (const fixed &a, const float b)
{ return fixed::divide(a,fixed(b)); }
inline fixed operator * (const fixed &a, const double b)
{ return fixed::multiply(a,fixed(b)); }
inline fixed operator * (const fixed &a, const float b)
{ return fixed::multiply(a,fixed(b)); }
/***************************************************************/
#endif /* SIDPLAY1_FIXPOINT_H */
|