| Q D E V _ H L P _ A B S ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English INDEP - PUBLIC
----------------------------------------------------------------------------
NAME
QDEV_HLP_ABS() - Absolutifies the value given so it is
always positive.
SYNOPSIS
abs = QDEV_HLP_ABS(a);
[LONG] QDEV_HLP_ABS([LONG]);
FUNCTION
This macro allows to turn possibly negative value into
a positive one.
INPUTS
a - Value of any type that can hold an integer.
RETURNS
Returns a if it is already positive or its absolutfied
eqiuvalent.
BASES
None.
NOTES
This macro can cause side effects, due to multiple arg.
evaluation! Make sure that what you pass are just the
arguments or constants or non-permanent statements.
SEE ALSO
QDEV_HLP_MIN(), QDEV_HLP_MAX(),
QDEV_HLP_NEG(), QDEV_HLP_FLIP()
EXAMPLE
#include <qdev.h>
...
LONG x = -6;
LONG z;
/*
* Example of the right usage, so no side effects will
* occurr.
*/
z = QDEV_HLP_ABS((x - 1));
/*
* Example of side effect statement which can turn the
* code into bad state.
*/
z = QDEV_HLP_ABS(x--);
...
BUGS
None known.
----------------------------------------------------------------------------
| |
| |