DEV Community

Discussion on: Daily Challenge #143 - Big Arithmetic

Collapse
 
yechielk profile image
Yechiel Kalmenson

Thankfully, Ruby automatically converts ints to Bignums when it detects an overflow, so the Ruby solution is as simple as:

def big_add(a, b)
  (a.to_i + b.to_i).to_s
end

def big_sub(a, b)
  (a.to_i - b.to_i).to_s
end