ITADN

What's the preferred way of comparing 2 Fractions?

#80Closedbali182 创建于 2024-10-21
B
bali182commented
I'm interested in what's the preferred way of comparing 2 fractionals. I see there is an equals method, but I'm interested in the `>`, `<`, `>=` and `<=` operators. From what I can see looking at the API, this is the most straightforward way of doing this: ```ts const a = new Fraction(1, 2) const b = new Fraction(1, 2) if (a.valueOf() > b.valueOf()) { // ... } ``` Is this the preferred way to compare 2 Fractionals? I see there is also this: ```ts if (a.compare(b) < 0) { // ... } ``` But this is not that great readability-wise.
关闭于 2024-10-30 7 条评论