Skip to content

Commit

Permalink
Bug fixes for num
Browse files Browse the repository at this point in the history
Adding number literals without conversion!
  • Loading branch information
aarikpokras authored Dec 24, 2024
1 parent 4d7970d commit e28d927
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions lib/io.cxlbund/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ struct num {
std::string as_str() {
return std::to_string(c);
}
num operator+(const num& o) {
return c + o.c;
num operator+(const int& o) {
return c + o;
}
num operator-(const num& o) {
num operator-(const int& o) {
return c - o.c;
}
num operator*(const num& o) {
num operator*(const int& o) {
return c * o.c;
}
num operator/(const num& o) {
num operator/(const int& o) {
return c / o.c;
}
void operator+=(const num& o) {
void operator+=(const int& o) {
c += o.c;
}
void operator-=(const num& o) {
void operator-=(const int& o) {
c -= o.c;
}
void operator*=(const num& o) {
void operator*=(const int& o) {
c *= o.c;
}
void operator/=(const num& o) {
void operator/=(const int& o) {
c /= o.c;
}
void operator++(int) {
Expand All @@ -47,42 +47,42 @@ struct num {
void operator--(int) {
c--;
}
bool operator==(const num& o) {
bool operator==(const int& o) {
if (c == o.c) {
return true;
} else {
return false;
}
}
bool operator!=(const num& o) {
bool operator!=(const int& o) {
if (c != o.c) {
return true;
} else {
return false;
}
}
bool operator>(const num& o) {
bool operator>(const int& o) {
if (c > o.c) {
return true;
} else {
return false;
}
}
bool operator<(const num& o) {
bool operator<(const int& o) {
if (c < o.c) {
return true;
} else {
return false;
}
}
bool operator>=(const num& o) {
bool operator>=(const int& o) {
if (c >= o.c) {
return true;
} else {
return false;
}
}
bool operator<=(const num& o) {
bool operator<=(const int& o) {
if (c <= o.c) {
return true;
} else {
Expand All @@ -92,9 +92,6 @@ struct num {
operator int() {
return c;
}
operator float() {
return c;
}
};

void loop(void (*what)(void), num times);
Expand Down

0 comments on commit e28d927

Please sign in to comment.