summaryrefslogtreecommitdiff log msg author committer range
path: root/pages
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
author committer Luc 2018-05-05 16:16:13 -0700 apache 2018-05-05 16:16:13 -0700 b2ef6743307960edf682414cdc249c0868fea712 (patch) a958489aed033848671f06d177a1f89d3b262f87 /pages 70146f5b760e7557b7fe33b99ff3a26a0146150c (diff)
Wiki page start changed with summary [The bitwise "not" is a tilde, not an exclamation mark. Mentioned logical operators separately to hopefully make it more accurate and clear.] by Luc
Diffstat (limited to 'pages')
-rw-r--r--pages/docs/c/start.txt2
1 files changed, 1 insertions, 1 deletions
 diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txtindex d7ccc6ecc..77ca1846c 100644--- a/pages/docs/c/start.txt+++ b/pages/docs/c/start.txt @@ -290,7 +290,7 @@ You can now replace all ''struct sandwich'' instances with ''Sandwich''. Take no 290 290 291 ==== Arithmetic ==== 291 ==== Arithmetic ==== 292 292 293 C supports all the usual mathematics you might want as well as boolean logic (binary logic operations). you can add (''+''), subtract (''-''), multiply (''*''), divide (''/''), modulo (''%''), and then to bit-wise bit logic with XOR (''^''), AND (''&''), OR (''|''), NOT (''!''). It is highly advised to group operations in braces like () to be clear on the order of operation you wanted. So ''%%x = a * b - c / d%%'' is unclear as to what you intended. It is wise to explicitly group like ''%%x = a * ((b - c) / d)%%''. The same goes for the bit-wise operations as well. 293 C supports all the usual mathematics you might want, as well as binary logic operations and boolean logic. You can add (''+''), subtract (''-''), multiply (''*''), divide (''/''), modulo (''%''), do bit-wise logic operations with XOR (''^''), AND (''&''), OR (''|''), NOT (''~''), or do boolean logic with operators such as AND (''&&''), OR (''||''), NOT (''!''). It is highly advised to group operations in braces like () to be clear on the order of operation you wanted. So ''%%x = a * b - c / d%%'' is unclear as to what you intended. It is wise to explicitly group like ''%%x = a * ((b - c) / d)%%''. The same goes for the bit-wise operations as well. 294 294 295 Note that this arithmetic starts falling apart if you try to add two structs (it doesn't work), as these are not normal integers or floating point values. You can add two pointers of the same type, but do not use ''void *'' for pointer arithmetic as it is unclear what the unit is. Normally a pointer has a unit size of its type size. Also bit-wise arithmetic isn't very useful on floating point values etc. 295 Note that this arithmetic starts falling apart if you try to add two structs (it doesn't work), as these are not normal integers or floating point values. You can add two pointers of the same type, but do not use ''void *'' for pointer arithmetic as it is unclear what the unit is. Normally a pointer has a unit size of its type size. Also bit-wise arithmetic isn't very useful on floating point values etc. 296 296