Project 6, 2015 Research Experience for Teachers Project 4, 2016
Arithmetic Operations, Integer

Secret Key, Public Key, Hash Algorithms, Protocols, Authentication, Integrity, Confidentiality, Availability

Instructions:
 Enter an integer in the upper left textfield labeled "number 1:" and an integer in the textfield below that is labeled "number 2:". Then select an operation (+,-,/,*) from the bottom button group. The binary representation of the two integers shows up in the four textfields to the right of each number. The rightmost byte of each group is the least significant. Integers are typically represented in a computer as a sequence of four bytes. The result of the selected operation shows up in the bottom left textfield labeled "result:". The binary value of the result is shown in the four bytes to its right. Try assigning number 1 the value -3, assigning number 2 the value 1 and adding. Try subtracting the number 3 from the number 1. Any surprises on the binary side?

Twos complement arithmetic:
 It should be easy to see that increasing positive numbers are represented in the sequence 0 (0), 1 (1), 10 (2), 11, (3), 100 (4), 101 (5), 110 (6), 111 (7), 100 (8) and so on. But the negative numbers, in sequence, are ...1111 (-1), ...1110 (-2), ...1101 (-3), ...1100 (-4), ...1011 (-5), ...1010 (-6), ...1001 (-7), ...1000 (-8) and so on. Here is the reason, by example: subtract 6 from 8. That's the same as adding 8 and -6. In binary, we add ...001000 to ...111010. This gives 1000...00010 where the leftmost 1 is outside the group of 4 bytes representing the result. So, we throw it out and what is left is the binary representation of the number 2. Try subtracting 8 from 6 or pick your own experiment. The particular representation of negative numbers (and thereby sacrifice of half of the representable positive numbers) is called twos complement representation and is used to make addition and subtraction easy by removing special cases.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://gauss.ececs.uc.edu/Project6/ArithLogic/ArithOpsInt/arithopsint.html", "fetch_time": 1680083570000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-14/segments/1679296948965.80/warc/CC-MAIN-20230329085436-20230329115436-00287.warc.gz", "warc_record_offset": 17373328, "warc_record_length": 2116, "token_count": 488, "char_count": 1967, "score": 3.84375, "int_score": 4, "crawl": "CC-MAIN-2023-14", "snapshot_type": "latest", "language": "en", "language_score": 0.8590387105941772, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00031-of-00064.parquet"}