栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

JAVA常见方法(Number类)2

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JAVA常见方法(Number类)2

(1)min()

返回两个参数中的最小值。

double min(double arg1, double arg2);
float min(float arg1, float arg2);
int min(int arg1, int arg2);
long min(long arg1, long arg2);
    System.out.println(Math.min(12.123, 12.456));      
    System.out.println(Math.min(23.12, 23.0));

(2)max()

返回两个参数中的最大值。

double max(double arg1, double arg2);
float max(float arg1, float arg2);
int max(int arg1, int arg2);
long max(long arg1, long arg2);
        System.out.println(Math.max(12.123, 18.456));      
        System.out.println(Math.max(23.12, 23.0)); 

(3)pow()

pow() 方法用于返回第一个参数的第二个参数次方。

double pow(double base, double exponent);
System.out.printf("pow(%.3f, %.3f) 为 %.3f%n", x, y, Math.pow(x, y));

(4)sqrt()

sqrt() 方法用于返回参数的算术平方根

double sqrt(double d);
System.out.printf("sqrt(%.3f) 为 %.3f%n", x, Math.sqrt(x));

(5)random()

random() 方法用于返回一个随机数,随机数范围为 0.0 =< Math.random < 1.0。

static double random();
System.out.println( Math.random() );

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/322137.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号