aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/sq.rst
blob: 2b6b1fe24c70d652aac5f82ea5ec4df225d8355a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.. highlight:: cpp

.. _arduino-sq:

sq(a)
=====

Description
-----------

(Macro) computes the square of a number.

Parameters
----------

**a**: the number.

Returns
-------

**a** squared (**a** × **a**).

Warning
-------

Because of the way ``sq()`` is implemented, avoid using other
functions or causing side effects inside the parentheses, as it may
lead to incorrect results::

    b = sq(a++);   // avoid this - yields incorrect results

    b = sq(a);     // use this instead -
    a++;           // keep other operations outside sq()


Arduino Compatibility
---------------------

Maple's implementation of ``sq()`` is compatible with Arduino.