See for details about precision, the format of valid numbers, and the operation rules for arithmetic. Note that if an arithmetic result is shown in exponential notation, it might have been rounded.

String class - arithmetic methods


5+5     ->    10
8-5     ->     3
5*2     ->    10
6/2     ->     3
9//4    ->     1
9%4     ->     2
2**3    ->     8
+5      ->     5             /* Prefix +  */
-5      ->    -5             /* Prefix -  */

Read Me - Common Public License V1.0 - Copyright Notice(©)

Arithmetic Methods


>>-arithmetic_operator(argument)-------------------------------><

Note

The syntax diagram above is for the non-prefix operators. The prefix + and [argument] .

Returns the result of performing the specified arithmetic operation on the receiver object. The receiver object and the [argument] must be valid numbers (see ). The [arithmetic_operator] can be:

+ + method method+ Addition
- - method method- Subtraction
* * method method* Multiplication
/ / method method/ Division
% % method method% Integer division (divide and return the integer part of the result)
// // method method// Remainder (divide and return the remainder—not modulo, because the result can be negative)
** ** method method** Exponentiation (raise a number to a whole-number power)
Prefix - methodprefix - Same as the subtraction: 0 - number
Prefix + methodprefix + Same as the addition: 0 + number

Read Me - Common Public License V1.0 - Copyright Notice(©)