21 out <<
"/" << a.den_ ;
34 int size = word.size();
37 std::size_t slashId = word.find(
'/');
38 bool hasSlash =
false;
39 if (slashId != std::string::npos) {
47 int numSize = slashId;
48 int denSize = size - slashId - 1;
49 std::string numStr = word.substr(0, numSize);
50 std::string denStr = word.substr(slashId + 1, denSize);
51 a.num_ = std::stoi(numStr);
52 a.den_ = std::stoi(denStr);
54 a.num_ = std::stoi(word);
A Rational number (a ratio of integers).
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Utility classes for scientific computation.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.