集册 Java实例教程 数学舍入函数

数学舍入函数

欢马劈雪     最近更新时间:2020-01-02 10:19:05

720
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
数学舍入函数

public class RoundingApp

{

  public static void main(String[] args)// 来 自 时 代 J     a    v  a - nowjava.com

  {

    double x = 9.4;

    double y = 3.5;

    double z = -9.3;


    System.out.println("round(x) = " + Math.round(x));

    System.out.println("round(y) = " + Math.round(y));

    System.out.println("round(z) = " + Math.round(z));

    System.out.println();

    System.out.println("ceil(x) = " + Math.ceil(x));

    System.out.println("ceil(y) = " + Math.ceil(y));

    System.out.println("ceil(z) = " + Math.ceil(z));

    System.out.println();

    System.out.println("floor(x) = " + Math.floor(x));

    System.out.println("floor(y) = " + Math.floor(y));

    System.out.println("floor(z) = " + Math.floor(z));

    System.out.println();
    /**
     * 时代Java公众号 - nowjava.com 提 供 
    **/

    System.out.println(
展开阅读全文