0
0

More than 1 year has passed since last update.

【Android】Mathクラスについてpart2【Kotlin】

Last updated at Posted at 2023-09-17

はじめに

前回に引き続き、Mathクラス内で使えそうなものを記事に残します!
前回よりは使わなそうだけど、もしかしたら使うなって感じ(自分基準)

max()

max(10,-8)   // 10

2つの数字の最大値

min()

min(10,-8)   // -8

2つの数字の最小値

pow()

5.pow(3)   // 125

累乗

PI

PI   // 3.141592653589793

円周率

random()

random()  // 0.6071951836875007 

0以上1未満の double 型の値をランダムに生成する

val range = (10..20)
range.random()   // 13

範囲を指定することで、その範囲内でランダムに値を生成する

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0