Classe Math

7 respostas
cu_ringa

alguem poderia me dizer o que esse método faz:

Math.ulp();

7 Respostas

louds

Que classe Math é essa?

furutani

“cu_ringa”:
alguem poderia me dizer o que esse método faz:

Math.ulp();


Eu acho que não existe, procurei no google e no eclipse.

MarcusGoncalves

Esse método foi adicionado no java 1.5.

MarcusGoncalves

public static double ulp(double d) Returns the size of an ulp of the argument. An ulp of a double value is the positive distance between this floating-point value and the double value next larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x).
Special Cases:

If the argument is NaN, then the result is NaN.
If the argument is positive or negative infinity, then the result is positive infinity.
If the argument is positive or negative zero, then the result is Double.MIN_VALUE.
If the argument is ±Double.MAX_VALUE, then the result is equal to 2971.

Parameters:
d - the floating-point value whose ulp is to be returned
Returns:
the size of an ulp of the argument
Since:
1.5


Tem também o public static float ulp(float f).

Bani

Deixa eu ver se entendi…
Essa classe vê o tamanho dos “buracos” no tipo double, em relação ao número que você gostaria de representar nele?

cu_ringa

ainda não entendi

louds

Hmm pelo que a descrição fala, e eu entendi, ulp(x) retorna o menor número positivo y tal que x + y != x

É o epslon relativo.

Isso, claro, se eu entendi corretamente.

Criado 3 de maio de 2004
Ultima resposta 4 de mai. de 2004
Respostas 7
Participantes 5