Math class for Java Common class library

Source: Internet
Author: User

http://www.verejava.com/?id=16993076554196

/**    知识点: Math 数学运算类*/public class TestMath{    public static void main(String[] args)    {        //取绝对值        System.out.println(Math.abs(-2));        //取大于小数的最小整数        System.out.println(Math.ceil(1.6));        System.out.println(Math.ceil(1.1));        //取小于小数的最大整数        System.out.println(Math.floor(1.6));        System.out.println(Math.floor(1.1));        //小数部分四舍五入        System.out.println(Math.round(1.6));        System.out.println(Math.round(1.1));        //取两个数的最大值        System.out.println(Math.max(1,2));        //取两个数的最小值        System.out.println(Math.min(1,2));        //生成0.0-1.0 之间的随机数        System.out.println(Math.random());    }}

http://www.verejava.com/?id=16993076554196

Math class for Java Common class library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.