日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > java >内容正文

java

math 计算float_Java Math类静态float min(float f1,float f2)与示例

發(fā)布時間:2025/3/11 java 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 math 计算float_Java Math类静态float min(float f1,float f2)与示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。