js Math物件方法 (個人學習筆記)

2022-04-02 00:23:50 字數 940 閱讀 7171

方法:

1.丟棄小數部分,保留整數部分

parseint(5/2)

2.向上取整,有小數就整數部分加1

math.ceil(5/2)

3,四捨五入.

math.round(5/2)

4,向下取整

math.floor(5/2)

5,返回數的絕對值

math.abs(x)

6,返回 x 和 y 中的最高值

math.max(x,y) 

7,返回 x 和 y 中的最低值

math.min(x,y)

8,返回 0 ~ 1 之間的隨機數

math.random()

9, 返回數的反余弦值

math.acos(x)

10,返回數的反正弦值

math.asin(x) 

11, 以介於 -pi/2 與 pi/2 弧度之間的數值來返回 x 的反正切值

math.atan(x)

12,返回從 x 軸到點 (x,y) 的角度(介於 -pi/2 與 pi/2 弧度之間)

math.atan2(y,x)

13,返回數的余弦

math.cos(x)

14,返回 e 的指數

math.exp(x) 

15,返回數的自然對數(底為e)

math.log(x)

16,返回 x 的 y 次冪

math.pow(x,y) 

17,返回數的正弦

math.sin(x) 

18,返回乙個角的正切

math.tan(x) 

19,返回數的平方根

math.sqrt(x) 

20,代表物件的源**

math.tosource() 

21,返回乙個 math 物件的原始值

math.valueof() 

js Math物件常用方法

math 物件用於執行數學任務。math 物件並不像 date 和 string 那樣是物件的類,因此沒有建構函式 math js 中math物件的常用方法 1.基本方法 math.round 5 2 對引數四捨五入為最接近的整數 3 math.ceil x 向上取整,有小數就整數部分加1 math...

持有物件(個人學習總結)

1.list arraylist與linkedlist區別 前者在隨機訪問元素方面有優勢,後者可以通過較低的代價進行插入與刪除。2.iterator迭代器iteratorit pets.inerator while it.hasnext 迭代器只能單向移動,迭代器統一了對容器的訪問 listiter...

js Date物件 (個人學習筆記)

date物件用於處理日期和 時間 1.直接獲取當前的時間為標準時間 var date new date wed may 30 2018 14 25 30 gmt 0800 中國標準時間 var date1 new date january 12,2006 22 19 35 可以傳入乙個時間 進行轉化...