Funciones y Operadores adicionales » Histórico » Revisión 1
Revisión 1/8
| Siguiente »
Federico Vera, 2018-07-12 17:38
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
)
Extra Functions¶
-
if(e, v_true, v_false)
: Branches the formula, it will be evaluated asv_true
ife == true()
andv_false
ife == false()
-
equals(a, b)
: Equivalent toa == b
, so the same conditions apply. -
sinc(x)
: Cardinal sine ofx
(not normalized), equivalent tosin(x)/x
Code¶
Actualizado por Federico Vera hace más de 6 años · 1 revisiones
Volver al inicio