Cody

# Problem 2678. Find out sum and carry of Binary adder

Solution 1936018

Submitted on 14 Sep 2019 by Hieu Vu
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 1; y=1; pc=1; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,1)) assert(isequal(carry,1))

sum = 1 carry = 1

2   Pass
x = 1; y=1; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,1))

sum = 0 carry = 1

3   Pass
x = 1; y=0; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,1)) assert(isequal(carry,0))

sum = 1 carry = 0

4   Pass
x = 0; y=0; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,0))

sum = 0 carry = 0

5   Pass
x = 1; y=1; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,1))

sum = 0 carry = 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.5077381,"math_prob":0.9996069,"size":901,"snap":"2020-45-2020-50","text_gpt3_token_len":340,"char_repetition_ratio":0.19509476,"word_repetition_ratio":0.23255815,"special_character_ratio":0.3862375,"punctuation_ratio":0.19907407,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.999972,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-30T17:29:08Z\",\"WARC-Record-ID\":\"<urn:uuid:e1fe60f8-e585-4ab7-b408-413804262373>\",\"Content-Length\":\"81508\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d0abf84f-686f-465b-b937-a591606fe501>\",\"WARC-Concurrent-To\":\"<urn:uuid:cde50857-a43f-45e3-9e80-a268ddd8e2b1>\",\"WARC-IP-Address\":\"23.223.252.57\",\"WARC-Target-URI\":\"https://nl.mathworks.com/matlabcentral/cody/problems/2678-find-out-sum-and-carry-of-binary-adder/solutions/1936018\",\"WARC-Payload-Digest\":\"sha1:SUWEXNKXMBBSX5PUEV2BH5QFBCJ4VZIY\",\"WARC-Block-Digest\":\"sha1:AU6IJVAIH7FGIWGR5E5L3DIY4FENZ5UC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107911027.72_warc_CC-MAIN-20201030153002-20201030183002-00053.warc.gz\"}"}