17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HXX
21 # include <vaucanson/misc/algebra.hh>
31 template<
typename IntType>
39 template<
typename IntType>
47 template<
typename IntType>
51 set_rational (num, den);
54 template<
typename IntType>
61 template<
typename IntType>
66 template<
typename IntType>
71 set_rational (num, den);
75 template<
typename IntType>
83 template<
typename IntType>
91 template<
typename IntType>
97 return ostr << num_ <<
'/' << den_;
101 template<
typename IntType>
111 template<
typename IntType>
121 template<
typename IntType>
129 template<
typename IntType>
139 template<
typename IntType>
150 template<
typename IntType>
156 set_rational (nb.
den_ / g * num_+ den_ / g * nb.
num_, den_ / g * nb.
den_);
160 template<
typename IntType>
166 set_rational (nb.
den_ / g * num_ - den_ / g * nb.
num_, den_ / g * nb.
den_);
170 template<
typename IntType>
177 set_unsafe_rational ((num_ / d1) * (nb.
num_ / d2),
178 (den_ / d2) * (nb.
den_ / d1));
182 template<
typename IntType>
187 assert(nb.
num_ != 0);
190 set_unsafe_rational ((num_ / d1) * (nb.
den_ / d2),
191 (nb.
num_ / d1) * (den_ / d2));
195 template<
typename IntType>
202 return (den_ == nb.
den_) && (num_ == nb.
num_);
205 template<
typename IntType>
210 return !(*
this == nb);
213 template<
typename IntType>
218 return (num_ * nb.
den_ < nb.
num_ * den_);
221 template<
typename IntType>
229 template<
typename IntType>
237 template<
typename IntType>
245 template<
typename IntType>
252 template<
typename IntType>
260 template<
typename IntType>
265 return (static_cast<float> (num_)) / den_;
268 template<
typename IntType>
273 return (static_cast<double> (num_)) / den_;
276 template<
typename IntType>
287 template<
typename IntType>
300 template<
typename IntType>
305 set_rational (num_, den_);
308 template<
typename IntType>
311 operator<< (std::ostream& ostr, const TRationalNumber<IntType>& nb)
317 template<
typename IntType>
320 operator>> (std::istream& istr, TRationalNumber<IntType>& a)
346 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HXX