上QQ阅读APP看书,第一时间看更新
Common operators
Beyond simple arithmetic there are many ways of dealing with our variables, each with its own syntax and effects on the different variable types. Let's discuss some of the most commonly used operators and variable functions.
Standard arithmetic
Addition ( +
), subtraction ( -
), multiplication ( *
), and division ( /
) work on all of the variable types we discussed, but have different effects on them. For floats and ints they work as we'd expect, but with multiplication and division, keep in mind the truncating that happens when working with ints.
It's also possible to use floats and ints together.