Golang operators: Difference between revisions
From wikinotes
(Created page with "= Arithmetic = <blockquote> <syntaxhighlight lang="go"> 1 + 1 // addition 1 - 1 // subtraction 1 * 1 // multiplication 1 / 1 // division 1 % 1 // modulus </syntaxhighlight> </...") |
|||
Line 1: | Line 1: | ||
= Arithmetic = | = Arithmetic = | ||
<blockquote> | <blockquote> | ||
Go requires that all variables involved in arithmetic are the same type.<br> | |||
(ex. uint8 + unit16 would fail to compile) | |||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> | ||
1 + 1 // addition | 1 + 1 // addition |
Revision as of 13:56, 29 May 2022
Arithmetic
Go requires that all variables involved in arithmetic are the same type.
(ex. uint8 + unit16 would fail to compile)1 + 1 // addition 1 - 1 // subtraction 1 * 1 // multiplication 1 / 1 // division 1 % 1 // modulus