{"id":3790,"date":"2023-03-01T22:55:24","date_gmt":"2023-03-02T03:55:24","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=3790"},"modified":"2023-03-01T22:55:24","modified_gmt":"2023-03-02T03:55:24","slug":"javascript-arithmetic-operators-breakdown-5a","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/03\/01\/javascript-arithmetic-operators-breakdown-5a\/","title":{"rendered":"JavaScript : Arithmetic Operators Breakdown &#8211; 5A"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3791\" src=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/js-300x150.png\" alt=\"\" width=\"300\" height=\"150\" srcset=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/js-300x150.png 300w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/js.png 318w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">In JavaScript, arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. There are four standard arithmetic operators, addition (+), subtraction (-), multiplication (*), and division (\/).<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">These operators work as they do in other programming languages except the division (\/) operator which returns a floating-point division in JavaScript, not a truncated division as it does in languages such as C or Java.<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">For example:<br \/>\n1\/2 returns 0.5 in JavaScript.<br \/>\n1\/2 returns 0 in Java.<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">In addition, JavaScript provides modules(%), increment(++), decrement(\u2013) and unary negation(-) operators.<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">Operator Name Purpose Example<br \/>\n+ Addition Adds two numbers together. 6 + 9<br \/>\n\u2013 Subtraction Subtracts the right number from the left. 20 \u2013 15<br \/>\n* Multiplication Multiplies two numbers together. 3 * 7<br \/>\n\/ Division Divides the left number by the right. 10 \/ 5<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">% Remainder (sometimes called modulo)<br \/>\nReturns the remainder left over after you\u2019ve divided the left number into a<br \/>\nnumber of integer portions equal to the right number.<br \/>\n8 % 3 (returns 2, as three goes into 8 twice, leaving 2 left over).<\/span><\/p>\n<p style=\"background: whitesmoke;margin: 0in 0in .25in 0in\"><span style=\"font-family: Raleway;color: #666666\">** Exponent Raises a base number to the exponent power, that is, the base number<br \/>\nmultiplied by itself, exponent times. 5 ** 2 (returns 25, which is the same as 5 * 5).<\/span><\/p>\n<p style=\"background: whitesmoke\"><span style=\"font-family: Raleway;color: #666666;background: whitesmoke\"><a href=\"https:\/\/www.w3resource.com\/javascript\/operators\/arithmetic-addition-subtraction-multiplication-division.php\">https:\/\/www.w3resource.com\/javascript\/operators\/arithmetic-addition-subtraction-multiplication-division.php<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In JavaScript, arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. There are four standard arithmetic operators, addition (+), subtraction (-), multiplication (*), and division (\/). These operators work as they do in other programming languages except the division (\/) operator which returns a floating-point division [&hellip;]<\/p>\n","protected":false},"author":29429,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[10531],"tags":[],"class_list":{"0":"post-3790","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-student-post","7":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/users\/29429"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=3790"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3790\/revisions"}],"predecessor-version":[{"id":3792,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3790\/revisions\/3792"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=3790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=3790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=3790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}