core :: Numeric :: sub
-
Numeric
assert 2.sub(1) == 1 assert 1.sub(0.1) == 0.9 assert 1.1.sub(0.1) == 1.0 assert 2.1.sub(1) == 1.1
# Universal `-` with any `Numeric` # # ~~~~ # assert 2.sub(1) == 1 # assert 1.sub(0.1) == 0.9 # assert 1.1.sub(0.1) == 1.0 # assert 2.1.sub(1) == 1.1 # ~~~~ fun sub(other: Numeric): Numeric is abstract
redef fun sub(other) do return self - other.to_f
redef fun sub(other) do if other isa Float then return to_f - other else return self - other.as(Int) end end