java math 类_Java Math类静态双层(double d)示例
java math 類
數(shù)學(xué)班靜態(tài)雙層(雙D) (Math Class static double floor(double d))
This method is available in java.lang package.
此方法在java.lang包中可用。
In this method if the value of the given positive argument after decimal point is 0 or greater than 0 so in that case it returns the same number before decimal point else if the value of the given negative argument after decimal point is greater than 0 so it returns (the same number +1) before decimal point.
在此方法中,如果給定的正參數(shù)的小數(shù)點(diǎn)后的值是0或大于0,那么在這種情況下,它在小數(shù)點(diǎn)前返回相同的數(shù)字,否則,如果給定的負(fù)參數(shù)的值后小數(shù)點(diǎn)后大于0,則它在小數(shù)點(diǎn)前返回(相同的數(shù)字+1)。
This is a static method so this method is accessible with the class name too.
這是一個靜態(tài)方法,因此也可以使用類名訪問此方法。
The return type of this method is double that means it returns the greatest floating-point value of the given argument and the argument value may be less than or equal to the given argument.
此方法的返回類型為double,這意味著它將返回給定參數(shù)的最大浮點(diǎn)值,并且參數(shù)值可能小于或等于給定參數(shù)。
In this method, we pass only one parameter as an argument in the method of Math class.
在此方法中,我們僅將一個參數(shù)作為參數(shù)傳遞給Math類的方法。
This method does not throw any exception.
此方法不會引發(fā)任何異常。
Syntax:
句法:
public static double floor(double d){}Parameter(s):
參數(shù):
double d – A double value whose greatest floating-poin value to be found.
double d-一個雙精度值,其最大浮點(diǎn)值將被找到。
Note:
注意:
If we pass "NaN", it returns "NaN".
如果我們傳遞“ NaN”,則返回“ NaN”。
If we pass a positive infinity, it returns the same i.e. a positive infinity.
如果我們傳遞一個正無窮大,它將返回相同的值,即一個正無窮大。
If we pass a negative infinity, it returns the same i.e. a negative infinity.
如果我們傳遞一個負(fù)無窮大,它將返回相同的值,即一個負(fù)無窮大。
If we pass 0 (-0 or 0), it returns the same.
如果我們傳遞0(-0或0),則返回相同值。
Return value:
返回值:
The return type of this method is double, it returns the greatest floating-point value of the given value.
此方法的返回類型為double ,它返回給定值的最大浮點(diǎn)值。
Java程序演示floor(double d)方法的示例 (Java program to demonstrate example of floor(double d) method)
// Java program to demonstrate the example of floor(double d) // method of Math Classpublic class FloorMethod {public static void main(String[] args) {// Here we are declaring few variablesdouble d1 = 7.0 / 0.0;double d2 = -7.0 / 0.0;double d3 = 0.0;double d4 = -0.0;double d5 = -123.1;double d6 = 123.456;// Display previous value of d1,d2,d3,d4,d5 and d6 System.out.println(" Before implementing floor() so the value of d1 is :" + d1);System.out.println(" Before implementing floor() so the value of d2 is :" + d2);System.out.println(" Before implementing floor() so the value of d3 is :" + d3);System.out.println(" Before implementing floor() so the value of d4 is :" + d4);System.out.println(" Before implementing floor() so the value of d4 is :" + d5);System.out.println(" Before implementing floor() so the value of d4 is :" + d6);// Here , we will get (Infinity) because we are passing parameter // whose value is (infinity)System.out.println("After implementing floor() so the value of d1 is :" + Math.floor(d1));// Here , we will get (-Infinity) because we are passing parameter // whose value is (-infinity)System.out.println("After implementing floor() so the value of d2 is :" + Math.floor(d2));// Here , we will get (0.0) because we are passing parameter // whose value is (0.0)System.out.println("After implementing floor() so the value of d3 is :" + Math.floor(d3));// Here , we will get (-0.0) because we are passing parameter // whose value is (-0.0)System.out.println("After implementing floor() so the value of d4 is :" + Math.floor(d4));// Here , we will get (-124.0) because we are passing parameter // whose value is (-123.1)System.out.println("After implementing floor() so the value of d5 is :" + Math.floor(d5));// Here , we will get (123.0) because we are passing parameter // whose value is (123.456)System.out.println("After implementing floor() so the value of d6 is :" + Math.floor(d6));} }Output
輸出量
E:\Programs>javac FloorMethod.javaE:\Programs>java FloorMethod Before implementing floor() so the value of d1 is :Infinity Before implementing floor() so the value of d2 is :-Infinity Before implementing floor() so the value of d3 is :0.0 Before implementing floor() so the value of d4 is :-0.0 Before implementing floor() so the value of d4 is :-123.1 Before implementing floor() so the value of d4 is :123.456After implementing floor() so the value of d1 is :Infinity After implementing floor() so the value of d2 is :-Infinity After implementing floor() so the value of d3 is :0.0 After implementing floor() so the value of d4 is :-0.0 After implementing floor() so the value of d5 is :-124.0 After implementing floor() so the value of d6 is :123.0翻譯自: https://www.includehelp.com/java/math-class-static-double-floor-double-d-with-example.aspx
java math 類
總結(jié)
以上是生活随笔為你收集整理的java math 类_Java Math类静态双层(double d)示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c# 赋值运算符_C#程序演示赋值运算符
- 下一篇: c语言两个浮点数相加_C语言中两个浮点数