Rational truncated () const;
void negate ();
operator bool () const;
+ operator int () const;
+ operator double () const;
operator String () const;
Rational operator - () const;
Rational ();
#include "string-convert.hh"
#include "libc-extension.hh"
-
Rational::operator bool () const
{
return sign_;
}
+Rational::operator int () const
+{
+ return sign_ * num_ / den_;
+}
+
+Rational::operator double () const
+{
+ return (double)sign_ * num_ / den_;
+}
+
ostream &
operator << (ostream &o, Rational r)
{