美文网首页
Android中Math常用的方法,包括pow、abs、roun

Android中Math常用的方法,包括pow、abs、roun

作者: 码农_小斌哥 | 来源:发表于2023-04-11 14:22 被阅读0次
  • 平方,立方,四次方--->pow
 Math.pow(10,2);//10的平方Math.pow(10,3);//10的立方Math.pow(10,4);//10的四次方
  • 绝对值--->abs
  Math.abs(-1);//1
  • 四舍五入--->round
Math.round(1.5);//2
Math.round(-1.5);//-1
Math.round(-1.6);//-2
  • 向下取整--->floor
Math.floor(-1.1);//-2
Math.floor(-1.4);//-2
Math.floor(-1.6);//-2Math.floor(1.1);//1
Math.floor(1.4);//1
Math.floor(1.6);//1
  • 向上取整--->rint
Math.rint(-1.1);//-1
Math.rint(-1.4);//-1
Math.rint(-1.6);//-1Math.rint(1.1);//2
Math.rint(1.4);//2
Math.rint(1.6);//2
  • 生成随机数--->random
Math.random();//生成0-1的double数
(Math.random() * (5 - 0) + 0);生成0-5的double数
(Math.random() * (50 - 10) + 10);生成10-50的double数
  • 取最小值--->min
Math.min(1, 2);//1

  • 取最大值--->max
Math.max(1, 2);//2
  • 开平方跟--->sqrt
Math.sqrt(2);//1.4142135623730951
Math.sqrt(4);//2.0
  • 开立方根--->cbrt
Math.cbrt(7);//1.9129311827723892
Math.cbrt(8);//2.0

相关文章

  • python内置函数

    math模块 在使用前导入math模块 import math 常用方法 math.pow()方法 math.p...

  • Python语言程序设计(五)

    常用的说明符 概念 1.Python提供数学函数:解释器里的abs、max、min、pow、和round;math...

  • math.对象

    console.log(Math.abs(10)); // 绝对值 console.log(Math.pow(2,...

  • 几个常用的Math函数

    00:Math.abs( ) //计算绝对值 01: Math.pow(x,y) //x的y次方 0...

  • JavaScript整理

    Math.random() 返回一个伪随机数; Math.abs() 返回x的绝对值; Math.pow(x,...

  • Math 对象

    Math 对象用于执行数学任务 Math 对象属性 Math 对象方法 abs() abs() 方法可返回数的绝对...

  • Java Math工具类

    1、Math.pow(x,y); 返回x的y次幂 2、Math.abs(x); 返回x的绝对值 3、Math.ra...

  • 前端零基础课程--第十五节课(Math)

    Math:数值的常用方法 属性:LOG10/LOG2/PI/.... 方法: abs(x) ceil(x)/rou...

  • Android中的Math.round(),Math.floor

    Math.round()方法: 表示的是“四舍五入”计算。Math.round(1.5) = 2Math.roun...

  • Math常用方法

    Math中常用的属性和方法 1.Math.abs([number value])获取绝对值(绝对值永远是正数或者零...

网友评论

      本文标题:Android中Math常用的方法,包括pow、abs、roun

      本文链接:https://www.haomeiwen.com/subject/claiddtx.html