math 计算float_Java Math类静态float min(float f1,float f2)与示例
math 計算float
數(shù)學(xué)類靜態(tài)浮點數(shù)min(float f1,float f2) (Math Class static float min(float f1 , float f2) )
This method is available in java.lang package.
此方法在java.lang包中可用。
This method is used to return the minimum one of both the given arguments or in other words this method returns the smallest value of the given two arguments.
此方法用于返回給定兩個參數(shù)中的最小值。換句話說,此方法返回給定兩個參數(shù)中的最小值。
This is a static method so this method is accessible with the class name too.
這是一個靜態(tài)方法,因此也可以使用類名訪問此方法。
The return type of this method is float, it returns the smallest element from the given two arguments.
此方法的返回類型為float ,它從給定的兩個參數(shù)返回最小的元素。
This method accepts two arguments of float values.
此方法接受浮點值的兩個參數(shù)。
This method does not throw any exception.
此方法不會引發(fā)任何異常。
Syntax:
句法:
public static float min(float f1, float f2){}Parameter(s): float f1, float f2 – two float values, in which we have to find the smallest/minimum value.
參數(shù): float f1,float f2 –兩個浮點值,我們必須在其中找到最小/最小值。
Return value:
返回值:
The return type of this method is float, it returns the smallest/minimum value.
此方法的返回類型為float ,它返回最小值/最小值。
Note:
注意:
If we pass "NaN" (Not a Number), it returns the same value i.e. "NaN".
如果我們傳遞“ NaN”(不是數(shù)字),它將返回相同的值,即“ NaN”。
If we pass zero (-0 or 0), it returns the 0.
如果傳遞零(-0或0),則返回0。
If we pass the same values in both parameters, it returns the same value.
如果我們在兩個參數(shù)中傳遞相同的值,則它將返回相同的值。
Java程序演示min(float f1,float f2)方法的示例 (Java program to demonstrate example of min(float f1, float f2) method)
// Java program to demonstrate the example of // min(float f1, float f2) method of Math Class.public class MinFloatTypeMethod {public static void main(String[] args) {// declaring variablesfloat f1 = -0.0f;float f2 = 0.0f;float f3 = -0.6f;float f4 = 124.58f;// displaying the valuesSystem.out.println("f1: " + f1);System.out.println("f2: " + f2);System.out.println("f3: " + f3);System.out.println("f4: " + f4);// Here , we will get (-0.0) because we are passing parameter // whose value is (-0.0f,0.0f)System.out.println("Math.min(f1,f2): " + Math.min(f1, f2));// Here , we will get (0.0) and we are passing parameter // whose value is (0.0f,124.58f)System.out.println("Math.min(f2,f4): " + Math.min(f2, f4));} }Output
輸出量
E:\Programs>javac MinFloatTypeMethod.javaE:\Programs>java MinFloatTypeMethod f1: -0.0 f2: 0.0 f3: -0.6 f4: 124.58 Math.min(f1,f2): -0.0 Math.min(f2,f4): 0.0翻譯自: https://www.includehelp.com/java/math-class-static-float-min-float-f1-float-f2-with-example.aspx
math 計算float
總結(jié)
以上是生活随笔為你收集整理的math 计算float_Java Math类静态float min(float f1,float f2)与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 修改console缓存大小_更改缓存的行
- 下一篇: Java BigInteger类| 带实