Dart的math库属性和方法以及类

在Dart主要库分三类

CORE,VM,WEB.各自包含多种类.Dart的math库属于CORE之一,比较常用,CORE还包含core库,io库,developer库,async库,collection库库,convert库,typed_data库,
这次主要将math库作介绍.使用它,需要导入库 import ‘dart:math’.

math库包含以下四个类

1)MutableRectangle ,A class for representing two-dimensional axis-aligned rectangles with mutable properties.
2)Point ,A utility class for representing two-dimensional positions.
3)Random ,A generator of random bool, int, or double values.
4)Rectangle ,A class for representing two-dimensional rectangles whose properties are immutable.

库math定义的常数Constants如下:

用→表示返回类型
e → const double ,Base of the natural logarithms. 值为2.718281828459045
ln2 → const double,Natural logarithm of 2. 值为0.6931471805599453
ln10 → const double , Natural logarithm of 10. 值为2.302585092994046
log2e → const double ,Base-2 logarithm of e.值为1.4426950408889634
log10e → const double, Base-10 logarithm of e.值为0.4342944819032518
pi → const double ,The PI constant.,值为3.1415926535897932
sqrt1_2 → const double, Square root of 1/2. 值为0.7071067811865476
sqrt2 → const double, Square root of 2.值为1.4142135623730951

库math的 Functions方法

基本根据字面英文能理解函数的功能
acos(num x) → double
Converts x to a double and returns its arc cosine in radians.

asin(num x) → double
Converts x to a double and returns its arc sine in radians.

atan(num x) → double
Converts x to a double and returns its arc tangent in radians.

atan2(num a num b) → double
A variant of atan.

cos(num radians) → double
Converts radians to a double and returns the cosine of the value.

exp(num x) → double
Converts x to a double and returns the natural exponent, e, to the power x.

log(num x) → double
Converts x to a double and returns the natural logarithm of the value.

max(T a T b) → T
Returns the larger of two numbers.

min(T a T b) → T
Returns the lesser of two numbers.

pow(num x num exponent) → num
Returns x to the power of exponent.

sin(num radians) → double
Converts radians to a double and returns the sine of the value.

sqrt(num x) → double
Converts x to a double and returns the positive square root of the value.

tan(num radians) → double
Converts radians to a double and returns the tangent of the value.

库math里的类后续将有补充.

1)MutableRectangle
2)Point ,关于坐标的类
3)Random 产生各种类型的随机数
4)Rectangle

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值