abs in java
// Java program to demonstrate working
// of java.lang.Math.abs() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
float a = 123.0f;
float b = -34.2323f;
double c = -0.0;
double d = -999.3456;
int e = -123;
int f = -0;
long g = -12345678;
long h = 98765433;
// abs() method taking float type as input
System.out.println(Math.abs(a));
System.out.println(Math.abs(b));
// abs() method taking double type as input
System.out.println(Math.abs(1.0 / 0));
System.out.println(Math.abs(c));
System.out.println(Math.abs(d));
// abs() method taking int type as input
System.out.println(Math.abs(e));
System.out.println(Math.abs(f));
System.out.println(Math.abs(Integer.MIN_VALUE));
// abs() method taking long type as input
System.out.println(Math.abs(g));
System.out.println(Math.abs(h));
System.out.println(Math.abs(Long.MIN_VALUE));
}
}
abs(intx);public class Test {
public static void main(String args[]) {
Integer a = -8;
double d = -100;
float f = -90;
System.out.println(Math.abs(a));
System.out.println(Math.abs(d));
System.out.println(Math.abs(f));
}
}
Also in Java:
- java constructor genertic
- java - a program to print open ports
- how to make a char uppercase in java
- java map foreach
- java pass array as method parameter
- java import biginteger
- islowercase java
- java string regexp replace
- How to draw Bezier Curve in Android
- java 8 findany on null list
- declare array java inline
- how to import an arraylist in java
- java observable
- how to select a random element from an array in java
- android studio clear views of layout
- Please ensure that your JAVA_HOME points to a valid Java SDK. You are currently pointing to: /usr/lib/jvm/java-13-oracle
- how to stop a void java
- create an empty array in java
- python to java converter
- android hide and show bottom navigation
- casting java
- validate request body java
- how do I change the opacity of a JButton
- hashmaps java