00001 #ifndef __FRACTION_H 00002 #define __FRACTION_H 00003 00004 #include <map> 00005 00010 class FractionConvert 00011 { 00013 struct Fraction 00014 { 00015 unsigned num; 00016 unsigned den; 00017 00019 Fraction(unsigned _num = 0, unsigned _den = 1) 00020 : num(_num), den(_den) 00021 {} 00022 00024 Fraction(const Fraction & f) 00025 : num(f.num), den(f.den) 00026 {} 00027 00029 Fraction & operator= (const Fraction & f) 00030 { 00031 if( &f != this) 00032 { 00033 num = f.num; 00034 den = f.den; 00035 } 00036 return *this; 00037 } 00038 }; 00039 00040 Fraction * frac; 00041 float * reel; 00042 unsigned nfrac; 00043 00044 public: 00046 FractionConvert(unsigned _n = 100); 00048 ~FractionConvert(); 00050 bool Approx(float nb, int & num, unsigned & den) const; 00051 }; 00052 00053 00054 #endif 00055