zoukankan      html  css  js  c++  java
  • Math 类的使用(一小部分)

     1 package com.Date.Math;
     2 /*
     3 Math 数学类, 主要是提供了很多的数学公式。
     4 
     5 abs(double a)  获取绝对值
     6 ceil(double a)  向上取整
     7 floor(double a)  向下取整
     8 round(float a)   四舍五入
     9 random()   产生一个随机数. 大于等于 0.0 且小于 1.0 的伪随机 double 值
    10 
    11 */
    12 public class Mathuse {
    13 
    14     public static void main(String[] args) {
    15         
    16         System.out.println("获取绝对值,"+Math.abs(3.14));
    17         
    18         System.out.println("向上取整,"+Math.ceil(-3.14));
    19         
    20         System.out.println("向下取整,"+Math.floor(3.14));
    21         
    22         System.out.println("四舍五入,"+Math.round(3.56));
    23         
    24         System.out.println("产生随机数,"+Math.random());
    25 
    26     }
    27 
    28 }

  • 相关阅读:
    L2-1 功夫传人 (25分)
    7-11 家庭房产(25 分)
    7-11 玩转二叉树 (25分)
    7-10 排座位 (25分)
    7-12 最长对称子串 (25分)
    7-10 树的遍历 (25分)
    STL
    Max Gcd
    水果
    Rails
  • 原文地址:https://www.cnblogs.com/fujilong/p/4687884.html
Copyright © 2011-2022 走看看