fabs

This function computes the absolute value of a float.

FABS

NAME

fabs - This function computes the absolute value of a float.

SYNOPSIS

fabs (number)

DESCRIPTION

This mathematical function allows the user to compute the absolute value of a float. The absolute value is equivalent to the modulo of the number, its positive value. It resemblances a distance. If the argument is a float or an integer, the function will simply return its positive value.

PARAMETERS

number
Specify the number (float) used as argument for the fabs function.

RETURN

The fabs value of the argument.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

One can use this function with integers:

test(q(res={_{fabs(-2);}}.),q(res=2.));
test(q(res={_{fabs(2);}}.),q(res=2.));

With floats:

test(q(res={_{fabs(-999.9);}}.),q(res=999.9.));

With defined variables:

test(q(res={_{
%include "/includes/extenso.sn";
fabs(-PI);
}}.),
q(res=PI.));

One another variable:

test(q(res={_{
%include "/includes/extenso.sn";
a=-3.1;
fabs(a);
}}.),
q(res=3.1.));

With a trigonometric function :

test(q(res={_{
%include "/includes/extenso.sn";
a=cos(PI);
fabs(a);
}}.),
q(res=1.));

With an array:

test(q(res={_{fabs(-1,2.5,-2.5);}}.),q(res=\[1,2.5,2.5\].));

SEE ALSO

{{ include("includes/maths.sn") }}

AUTHOR

Written by Caroline Laplante, <claplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.