lib/hpsqrt.rb in hpsqrt-1.4.0 vs lib/hpsqrt.rb in hpsqrt-1.5.0
- old
+ new
@@ -176,11 +176,11 @@
def expr
value_to_s = -> (v) {
if Complex===v && v.imag.zero?
v = v.real
end
- if Rational===v
- v = v.to_s.sub(/\/1$/, "")
+ if Rational===v && v.denominator==1
+ v = v.numerator
end
v = v.to_s
if v !~ /^[\d\.]+$/
v = "(%s)" % v
end