StrictMath class ULP () método : Aquí, vamos a aprender sobre el método ULP () de StrictMath Class con su sintaxis y su ejemplo.
StrictMath Class ULP () método
Sintaxis:
public static float signum(float fl);
public static double signum(double d);
- ULP () Método está disponible en java.lang Class.
- ULP (package hacer) Método se utiliza para float el tamaño de un
- ULP del parámetro de valor return dado es la distancia positiva entre el valor de punto flotante float y el valor double argumento dado siguiente más grande en magnitud.
- ULP (return fl) Método
- del argumento dado en el método. En este método, un
ULP
del argumento dado en el método. En este método, un
se utiliza para double el tamaño de un
ULP
ULP
del parámetro de valor throw dado es la distancia positiva entre el valor de punto flotante static y el valor class argumento dado siguiente más grande en magnitud.
Estos métodos no class una excepción.
Estos son métodos class, es accesible con el nombre float y, si tratamos de acceder a estos métodos con el objeto double entonces no vamos a tener ningún error.
- Parámetro (s):
Return / return
– representa el valor representa el valor de punto flotante class cuya
ULP
es para ser devuelto.
float valor:
- El tipo double del método es
- , devuelve el tamaño de un ULP del parámetro dado y el valor _CR25_ es de tipo _CR26_ / _CR27_.
_CR23_ / _CR24_
Nota:
Si pasamos NaN, el método devuelve el mismo valor (es decir, NaN).
Si pasamos un infinito (positivo o negativo), el método devuelve el infinito positivo.
Si pasamos cero (positivo o negativo), el método devuelve el
_CR28_ .MIN_VALUE
/
_CR29_ .MIN_VALUE
.
Si pasamos
_CR30_ .MAX_VALUE
, el método devuelve el 2 elevado a la potencia de 104 y si pasamos
_CR31_ .MAX_VALUE
, el método devuelve el 2 elevado a la potencia de 971.
Ejemplo:
// Java program to demonstrate the example
// of signum() method of StrictMath class
public class Signum {
public static void main(String[] args) {
// variable declarations
float f1 = -0.0f;
float f2 = 0.0f;
float f3 = -0.6f;
float f4 = 2.0f;
double d1 = -0.0;
double d2 = 0.0;
double d3 = -0.6;
double d4 = 2.0;
System.out.println("signum(float fl): ");
// Here, we will get (-0.0) because we are passing
// parameter whose value is (-0.0f)
System.out.println("StrictMath.signum(f1): " + StrictMath.signum(f1));
// Here, we will get (0.0) and we are passing
// parameter whose value is (0.0f)
System.out.println("StrictMath.signum(f2): " + StrictMath.signum(f2));
// Here, we will get (-1.0) and we are passing
// parameter whose value is (-0.6f)
System.out.println("StrictMath.signum( f3): " + StrictMath.signum(f3));
// Here, we will get (1.0) and we are passing
// parameter whose value is (2.0f)
System.out.println("StrictMath.signum( f4): " + StrictMath.signum(f4));
System.out.println();
System.out.println("signum(double d): ");
// Here, we will get (-0.0) because we are passing
// parameter whose value is (-0.0)
System.out.println("StrictMath.signum(d1): " + StrictMath.signum(d1));
// Here, we will get (0.0) and we are passing
// parameter whose value is (0.0)
System.out.println("StrictMath.signum(d2): " + StrictMath.signum(d2));
// Here, we will get (-1.0) and we are passing
// parameter whose value is (-0.6)
System.out.println("StrictMath.signum(d3): " + StrictMath.signum(d3));
// Here, we will get (1.0) and we are passing
// parameter whose value is (2.0)
System.out.println("StrictMath.signum(d4): " + StrictMath.signum(d4));
}
}
salida
signum(float fl):
StrictMath.signum(f1): -0.0
StrictMath.signum(f2): 0.0
StrictMath.signum( f3): -1.0
StrictMath.signum( f4): 1.0
signum(double d):
StrictMath.signum(d1): -0.0
StrictMath.signum(d2): 0.0
StrictMath.signum(d3): -1.0
StrictMath.signum(d4): 1.0
_127_ _128_ _129_ _130_ _131_ _132_ _133_ _134_ _135_ _136_ _137_ _138_ _139_ _140_ _141_ _142_ _143_ _144_