Java Math.ceil() yöntemi
java.lang.Math.ceil () Bağımsız değişkene veya matematiksel tam sayıya eşit veya ondan büyük olan en küçük tam sayı değerini bulmak için kullanılır.
Sözdizimi
public static double ceil(double x)
Parametre
x= a value
Geri dönmek
This method returns smallest floating-point value that is greater than or equal to the argument and is equal to a mathematical integer.
- Argüman pozitif veya negatif çift değer ise, bu yöntem şunu döndürür: tavan değeri .
- Eğer argüman NaN , bu yöntem geri dönecektir aynı argüman .
- Eğer argüman Sonsuzluk , bu yöntem geri dönecektir Sonsuzluk argümanla aynı işaretle.
- Argüman olumlu ya da olumsuz ise Sıfır , bu yöntem geri dönecektir Sıfır argümanla aynı işaretle.
- Argüman Sıfırdan küçük ancak -1,0'dan büyükse bu yöntem şunu döndürür: Negatif Sıfır olarak çıktı.
örnek 1
public class CeilExample1 { public static void main(String[] args) { double x = 83.56; // Input positive value, Output ceil value of x System.out.println(Math.ceil(x)); } } Şimdi Test Edin Çıktı:
84.0
Örnek 2
public class CeilExample2 { public static void main(String[] args) { double x = -94.73; // Input negative value, Output ceil value of x System.out.println(Math.ceil(x)); } } Şimdi Test Edin Çıktı:
-94.0
Örnek 3
public class CeilExample3 { public static void main(String[] args) { double x = -1.0 / 0; // Input negative infinity, Output negative infinity System.out.println(Math.ceil(x)); } } Şimdi Test Edin Çıktı:
-Infinity
Örnek 4
public class CeilExample4 { public static void main(String[] args) { double x = 0.0; // Input positive zero, Output positive zero System.out.println(Math.ceil(x)); } } Şimdi Test Edin Çıktı:
0.0
Örnek 5
public class CeilExample5 { public static void main(String[] args) { double x = -0.25; // Input less than zero but greater than -1.0, Output negative zero System.out.println(Math.ceil(x)); } } Şimdi Test Edin Çıktı:
-0.0