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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java-number2

發(fā)布時間:2025/4/16 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java-number2 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

abs() :該方法給出了參數(shù)的絕對值,參數(shù)可以是int,float,long,double,short,byte

Syntax double abs(double d) float abs(float f) int abs(int i) long abs(long lng)public class Test { public static void main(String args[]) {Integer a = -8;double d = -100;float f = -90;System.out.println(Math.abs(a));System.out.println(Math.abs(d)); System.out.println(Math.abs(f)); } }


ceil():該方法給出大于或等于參數(shù)的最小整數(shù)

Syntax double ceil(double d) double ceil(float f)public class Test { public static void main(String args[]) {double d = -100.675;float f = -90; System.out.println(Math.ceil(d));System.out.println(Math.ceil(f)); System.out.println(Math.floor(d));System.out.println(Math.floor(f)); } }


floor() 該方法給出小于或等于參數(shù)的最大整數(shù)

Syntax double floor(double d) double floor(float f)public class Test { public static void main(String args[]) {double d = -100.675;float f = -90;System.out.println(Math.floor(d));System.out.println(Math.floor(f)); System.out.println(Math.ceil(d));System.out.println(Math.ceil(f));} }


rint():返回值最接近參數(shù)的整數(shù)

Syntax double rint(double d)public class Test {public static void main(String args[]) {double d = 100.675;double e = 100.500;double f = 100.200;System.out.println(Math.rint(d));System.out.println(Math.rint(e)); System.out.println(Math.rint(f)); } }


round():返回最接近的long或int

Syntax This method has the following variants ?long round(double d) int round(float f)public class Test { public static void main(String args[]) {double d = 100.675;double e = 100.500;float f = 100;float g = 90f;System.out.println(Math.round(d));System.out.println(Math.round(e)); System.out.println(Math.round(f)); System.out.println(Math.round(g)); } }


min():給出兩個參數(shù)的最小值,參數(shù)可以是int,float,long,double

Syntax This method has the following variants ?double min(double arg1, double arg2) float min(float arg1, float arg2) int min(int arg1, int arg2) long min(long arg1, long arg2)public class Test {public static void main(String args[]) {System.out.println(Math.min(12.123, 12.456)); System.out.println(Math.min(23.12, 23.0)); } }


max() 給出兩個參數(shù)最大值,參數(shù)可以是int,float,long,double

Syntax This method has the following variants ?double max(double arg1, double arg2) float max(float arg1, float arg2) int max(int arg1, int arg2) long max(long arg1, long arg2)public class Test { public static void main(String args[]) {System.out.println(Math.max(12.123, 12.456)); System.out.println(Math.max(23.12, 23.0)); } } ![](https://images2018.cnblogs.com/blog/1202026/201806/1202026-20180606230843119-1176811323.png)

pow():返回第一個參數(shù)基于第二參數(shù)次方的值

public class Test { public static void main(String args[]) {double x = 11.635;double y = 2.76;System.out.printf("The value of e is %.4f%n", Math.E);System.out.printf("pow(%.3f, %.3f) is %.3f%n", x, y, Math.pow(x, y));} }


Math.sqrt() 平方根
Math.sin()
Math.cos()
Math.tan()
....
Math.random() 產(chǎn)生一個0到1的隨機(jī)數(shù)

轉(zhuǎn)載于:https://www.cnblogs.com/cyany/p/9147964.html

總結(jié)

以上是生活随笔為你收集整理的java-number2的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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