strictmath_Java StrictMath ceil()方法与示例
strictmath
StrictMath類ceil()方法 (StrictMath Class ceil() method)
ceil() method is available in java.lang package.
ceil()方法在java.lang包中可用。
ceil() method is used to return the least or smallest value of the double type value which is greater than or equal to the given parameter.
ceil()方法用于返回大于或等于給定參數(shù)的double類型值的最小值或最小值。
ceil() method is a static method so this method is accessible with the class name too.
ceil()方法是靜態(tài)方法,因此也可以使用類名訪問此方法。
ceil() method does not throw any exception at the time of ceiling the given parameter.
在給定參數(shù)設(shè)置上限時(shí), ceil()方法不會(huì)引發(fā)任何異常。
Syntax:
句法:
public static double ceil(double d);Parameter(s):
參數(shù):
double d – represents the double type value whose least value to be found.
double d –表示要找到其最小值的double類型值。
Return value:
返回值:
The return type of this method is double – it returns least value of the given parameter.
該方法的返回類型為double-返回給定參數(shù)的最小值。
Note:
注意:
If we pass NaN as an argument, method returns the same value (NaN).
如果我們將NaN作為參數(shù)傳遞,則方法將返回相同的值(NaN)。
If we pass zero (0), method returns the same value with the same sign.
如果傳遞零(0),則方法將返回具有相同符號(hào)的相同值。
If we pass an infinity, method returns the same value with the same sign.
如果我們傳遞一個(gè)無窮大,則方法將返回帶有相同符號(hào)的相同值。
If we pass an argument which is less than 0, but greater than -1.0, method returns -0.0.
如果我們傳遞的參數(shù)小于0但大于-1.0,則方法返回-0.0。
If we pass an argument whose value after the decimal point is greater than 0, method returns the value incremented by 1.
如果我們傳遞的參數(shù)的小數(shù)點(diǎn)后的值大于0,則方法返回的值將增加1。
Example:
例:
// Java program to demonstrate the example // of ceil(double d) method of StrictMath Class.public class Ceil {public static void main(String[] args) {// Variable Declarationdouble d1 = -0.0;double d2 = 0.0;double d3 = -7.0 / 0.0;double d4 = 7.0 / 0.0;double d5 = -0.6;double d6 = 1000.0;double d7 = 1000.4;// Display previous value of d1,d2,d3,d4,d5 ,d6 and d7System.out.println("d1: " + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);System.out.println("d4: " + d4);System.out.println("d5: " + d5);System.out.println("d6: " + d6);System.out.println("d7: " + d7);// Here , we will get (-0.0) because we are passing // parameter (-0.6) because passed value is less than 0 // but greater than -1.0System.out.println("StrictMath.ceil(d1): " + StrictMath.ceil(d1));// Here , we will get (0.0) because we are passing parameter (0.0)System.out.println("StrictMath.ceil(d2): " + StrictMath.ceil(d2));// Here , we will get (-Infinity) because we are passing parameter (-7.0/0.0) System.out.println("StrictMath.ceil(d3): " + StrictMath.ceil(d3));// Here , we will get (Infinity) because we are passing parameter (7.0/0.0) System.out.println("StrictMath.ceil(d4): " + StrictMath.ceil(d4));// Here , we will get (-0.0) because we are passing // parameter (-0.6) because passed value is less than 0 // but greater than -1.0System.out.println("StrictMath.ceil(d5): " + StrictMath.ceil(d5));// Here , we will get (1000.0) because we are passing // parameter (1000.0) because passed value after decimal // point is not greater than 0 so the same number is //returnedSystem.out.println("StrictMath.ceil(d6): " + StrictMath.ceil(d6));// Here , we will get (1001.0) because we are passing // parameter (1000.4) because passed value after decimal // point is greater than 0 so the number is incremented by 1 is returnedSystem.out.println("StrictMath.ceil(d7): " + StrictMath.ceil(d7));} }Output
輸出量
d1: -0.0 d2: 0.0 d3: -Infinity d4: Infinity d5: -0.6 d6: 1000.0 d7: 1000.4 StrictMath.ceil(d1): -0.0 StrictMath.ceil(d2): 0.0 StrictMath.ceil(d3): -Infinity StrictMath.ceil(d4): Infinity StrictMath.ceil(d5): -0.0 StrictMath.ceil(d6): 1000.0 StrictMath.ceil(d7): 1001.0翻譯自: https://www.includehelp.com/java/strictmath-ceil-method-with-example.aspx
strictmath
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的strictmath_Java StrictMath ceil()方法与示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java treemap_Java Tr
- 下一篇: 为什么DNF游戏老是卡安全状态!!!!求