GNU Info

Info Node: (mysql.info)Arithmetic functions

(mysql.info)Arithmetic functions


Next: Mathematical functions Prev: Numeric Functions Up: Numeric Functions
Enter node , (file) or (file)node

Arithmetic Operations
.....................

The usual arithmetic operators are available. Note that in the case of
`-', `+', and `*', the result is calculated with `BIGINT' (64-bit)
precision if both arguments are integers!

`+'
     Addition:
          mysql> select 3+5;
                  -> 8

`-'
     Subtraction:
          mysql> select 3-5;
                  -> -2

`*'
     Multiplication:
          mysql> select 3*5;
                  -> 15
          mysql> select 18014398509481984*18014398509481984.0;
                  -> 324518553658426726783156020576256.0
          mysql> select 18014398509481984*18014398509481984;
                  -> 0

     The result of the last expression is incorrect because the result
     of the integer multiplication exceeds the 64-bit range of `BIGINT'
     calculations.

`/'
     Division:
          mysql> select 3/5;
                  -> 0.60

     Division by zero produces a `NULL' result:

          mysql> select 102/(1-1);
                  -> NULL

     A division will be calculated with `BIGINT' arithmetic only if
     performed in a context where its result is converted to an integer!


automatically generated by info2www version 1.2.2.9