Problem 564. How to subtract?
Solution Stats
Problem Comments
-
8 Comments
Show
5 older comments
Mohamed Atyya
on 30 Oct 2017
good
nipun garg
on 8 Jun 2018
function z = mysub(x,y)
z = num2str( str2num(x) - str2num(y) );
end
why this is not working for this code?
Matt Offredi
on 8 Mar 2019
Nice
Mark Sanderson
on 14 Mar 2019
Hi. My code only prints out '-' for a negative number but not '+' for a positive. Can anyone help? function Z = mysub(X,Y); W = (str2num(X))-(str2num(Y)); Z = num2str(W); end
Rafael S.T. Vieira
on 2 Jul 2020
actually each of them has 14 characters or less...15 if we count the signs.
Rafael S.T. Vieira
on 2 Jul 2020
Mark Sanderson, if W > 0 Z = ['+' ...]
Valeriu Mihailov
on 28 May 2022
how about solving this problem but not using any conversion functions like num2str , str2num , str2double ...
Brandon
on 5 Jun 2023
This problem needed much larger test cases. At least beyond intmax('uint64') range. Also negative inputs were not implemented at all.
Solution Comments
Show comments
Problem Recent Solvers1494
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!