Problem 2522. Convert given decimal number to binary number.
Solution Stats
Problem Comments
-
1 Comment
Nice
Solution Comments
-
2 Comments
Wow mine one so much complex dont think str2num can do that
I used str2num
-
1 Comment
why 'de2bi()' & 'bi2de()' functions don't work here although they work in MATLAB online?!
-
1 Comment
whereas str2double(dec2bin(x) succeeds, I dont agree it is correct.
str2double(dec2bin(10)) -> 1010
str2double(dec2bin(10)) + 2 -> 1012 ;
this makes little sense in decimal nor in binary code.
I suggest correcting the check to y_correct ='1010'
-
2 Comments
Why doesn't the built in function dec2bin() work here?
dec2bin returns a character vector, the answer must be an int type
Problem Recent Solvers1534
Suggested Problems
-
3970 Solvers
-
Extract leading non-zero digit
1751 Solvers
-
19693 Solvers
-
How many trades represent all the profit?
576 Solvers
-
567 Solvers
More from this Author70
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!