Funciones y Operadores adicionales » Histórico » Revisión 2
« Anterior |
Revisión 2/8
(diferencias)
| Siguiente »
Federico Vera, 2018-07-12 17:41
Funciones y Operadores adicionales¶
- Índice de contenidos
- Funciones y Operadores adicionales
There are a number of extra functions and operators included in this version of exp4j
, non of this are enabled by default, they are in the net.objecthunter.exp4j.extras
package.
Comparison Operators¶
Aside from the arithmetic operators several comparison operators are included: <
, <=
, >
, >=
, !=
and ==
.
Please note that since exp4j
itself has no concept of boolean
, the results given by all of the comparison operators will be 1.0
if true
and 0.0
if false
. Let it be noted that due to rounding, equality operators use a radix in which they consider numbers to be "equal", that is:
Let a
and b
be two real numbers, a == b
will evaluate to true
if and only if the distance between a
and b
(dist(a, b) := abs(a - b)
) is less or equal than 1e-12
(0.000000000001
) and false
otherwise.
Precedence¶
Operator precedence is altered when using the comparison operators, the new precedence is:
FIRST-> * / % - + > >= < <= ¬ & | == != <-LAST
----- --- --------- - - - -----
^^^ The dashes indicate groups with the same precedence
Funciones lógicas¶
Even though we have boolean operators, there are also a number of boolean functions that can be used (some people prefer functions)
-
and(a, b)
: Y lógico equivalente aa & b
-
or(a, b)
: O lógico equivalente aa | b
-
xor(a, b)
: O exclusivo -
nand(a, b)
: equivalente a¬(a & b)
-
nor(a, b)
: equivalente a¬(a | b)
-
xnor(a, b)
: O exclusivo negado -
not(a)
: equivalente a¬a
Constantes lógicas¶
-
true()
: verdadero (1.0
) (se considera como verdadero a cualquier valor distinto de cero, pero la funcióntrue()
devuelve1.0
así como los operadores booleans y de comparación. -
false()
: falso (0.0
)
Funciones adicionales¶
-
if(e, v_true, v_false)
: Ramifica la expresión, se evalúa comov_true
sie == true()
yv_false
sie == false()
-
equals(a, b)
: Equivalente aa == b
, por lo tanto se cumplen las mismas condiciones. -
sinc(x)
: Seno cardinal dex
(no normalizado), equivalente asin(x)/x
Código¶
Actualizado por Federico Vera hace más de 6 años · 2 revisiones
Volver al inicio