博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
math 计算float_Java Math类静态float min(float f1,float f2)与示例
阅读量:2527 次
发布时间:2019-05-11

本文共 2491 字,大约阅读时间需要 8 分钟。

math 计算float

数学类静态浮点数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.

    此方法用于返回给定两个参数中的最小值。换句话说,此方法返回给定两个参数中的最小值。

  • This is a static method so this method is accessible with the class name too.

    这是一个静态方法,因此也可以使用类名访问此方法。

  • The return type of this method is float, it returns the smallest element from the given two arguments.

    此方法的返回类型为float ,它从给定的两个参数返回最小的元素。

  • This method accepts two arguments of float values.

    此方法接受浮点值的两个参数。

  • This method does not throw any exception.

    此方法不会引发任何异常。

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.

参数: 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”(不是数字),它将返回相同的值,即“ 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.

    如果我们在两个参数中传递相同的值,则它将返回相同的值。

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 variables float f1 = -0.0f; float f2 = 0.0f; float f3 = -0.6f; float f4 = 124.58f; // displaying the values System.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 MinFloatTypeMethodf1: -0.0f2: 0.0f3: -0.6f4: 124.58Math.min(f1,f2): -0.0Math.min(f2,f4): 0.0

翻译自:

math 计算float

转载地址:http://wjtzd.baihongyu.com/

你可能感兴趣的文章
django登录验证码操作
查看>>
(简单)华为Nova青春 WAS-AL00的USB调试模式在哪里开启的流程
查看>>
UIScrollerView ,UIPageControl混搭使用,添加定时器,无限循环滚动
查看>>
图论知识,博客
查看>>
微信企业号开发之-如何获取secret 序列号
查看>>
2015年最新Android基础入门教程目录(完结版)
查看>>
[原创]一篇无关技术的小日记(仅作暂存)
查看>>
20145303刘俊谦 Exp7 网络欺诈技术防范
查看>>
原生和jQuery的ajax用法
查看>>
iOS开发播放文本
查看>>
20145202马超《java》实验5
查看>>
JQuery 事件
查看>>
main(argc,argv[])
查看>>
源码:Java集合源码之:哈希表(二)
查看>>
【HDU 3709】 Balanced Number (数位DP)
查看>>
JsonPath的使用
查看>>
企业常用的站内收索、QQ群、在线客服
查看>>
Centos下安装nginx步骤解析
查看>>
EntityFramework Code First 添加唯一键
查看>>
在线教育工具—白板系统的迭代1——bug监控排查
查看>>