round() 四舍五入 roundToDouble() 返回的是小数
floor() 往X轴左侧约 floorToDouble() 返回的是小数
ceil() 往X轴右侧约 ceilToDouble() 返回的是小数
truncate() 往原点约 truncateToDouble() 返回的是小数
clamp(num lowerLimit, num upperLimit);
生成的数在范围内取值,如
/// var result = 10.5.clamp(5, 10.0); // 10.0 /// result = 0.75.clamp(5, 10.0); // 5 /// result = (-10).clamp(-5, 5.0); // -5 /// result = (-0.0).clamp(-5, 5.0); // -0.0
/// Returns the integer closest to this number.
///
/// Rounds away from zero when there is no closest integer:
/// `(3.5).round() == 4` and `(-3.5).round() == -4`.
///
/// Throws an [UnsupportedError] if this number is not finite
/// (NaN or an infinity).
/// ```dart
/// print(3.0.round()); // 3
/// print(3.25.round()); // 3
/// print(3.5.round()); // 4
/// print(3.75.round()); // 4
/// print((-3.5).round()); // -4
/// ```
int round();
/// Returns the greatest integer no greater than this number.
///
/// Rounds the number towards negative infinity.
///
/// Throws an [UnsupportedError] if this number is not finite
/// (NaN or infinity).
/// ```dart
/// print(1.99999.floor()); // 1
/// print(2.0.floor()); // 2
/// print(2.99999.floor()); // 2
/// print((-1.99999).floor()); // -2
/// print((-2.0).floor()); // -2
/// print((-2.00001).floor()); // -3
/// ```
int floor();
/// Returns the least integer that is not smaller than this number.
///
/// Rounds the number towards infinity.
///
/// Throws an [UnsupportedError] if this number is not finite
/// (NaN or an infinity).
/// ```dart
/// print(1.99999.ceil()); // 2
/// print(2.0.ceil()); // 2
/// print(2.00001.ceil()); // 3
/// print((-1.99999).ceil()); // -1
/// print((-2.0).ceil()); // -2
/// print((-2.00001).ceil()); // -2
/// ```
int ceil();
/// Returns the integer obtained by discarding any fractional
/// part of this number.
///
/// Rounds the number towards zero.
///
/// Throws an [UnsupportedError] if this number is not finite
/// (NaN or an infinity).
/// ```dart
/// print(2.00001.truncate()); // 2
/// print(1.99999.truncate()); // 1
/// print(0.5.truncate()); // 0
/// print((-0.5).truncate()); // 0
/// print((-1.5).truncate()); // -1
/// print((-2.5).truncate()); // -2
/// ```
int truncate();
/// Returns the integer double value closest to `this`.
///
/// Rounds away from zero when there is no closest integer:
/// `(3.5).roundToDouble() == 4` and `(-3.5).roundToDouble() == -4`.
///
/// If this is already an integer valued double, including `-0.0`, or it is not
/// a finite value, the value is returned unmodified.
///
/// For the purpose of rounding, `-0.0` is considered to be below `0.0`,
/// and `-0.0` is therefore considered closer to negative numbers than `0.0`.
/// This means that for a value `d` in the range `-0.5 < d < 0.0`,
/// the result is `-0.0`.
/// ```dart
/// print(3.0.roundToDouble()); // 3.0
/// print(3.25.roundToDouble()); // 3.0
/// print(3.5.roundToDouble()); // 4.0
/// print(3.75.roundToDouble()); // 4.0
/// print((-3.5).roundToDouble()); // -4.0
/// ```
double roundToDouble();
/// Returns the greatest integer double value no greater than `this`.
///
/// If this is already an integer valued double, including `-0.0`, or it is not
/// a finite value, the value is returned unmodified.
///
/// For the purpose of rounding, `-0.0` is considered to be below `0.0`.
/// A number `d` in the range `0.0 < d < 1.0` will return `0.0`.
/// ```dart
/// print(1.99999.floorToDouble()); // 1.0
/// print(2.0.floorToDouble()); // 2.0
/// print(2.99999.floorToDouble()); // 2.0
/// print((-1.99999).floorToDouble()); // -2.0
/// print((-2.0).floorToDouble()); // -2.0
/// print((-2.00001).floorToDouble()); // -3.0
/// ```
double floorToDouble();
/// Returns the least integer double value no smaller than `this`.
///
/// If this is already an integer valued double, including `-0.0`, or it is not
/// a finite value, the value is returned unmodified.
///
/// For the purpose of rounding, `-0.0` is considered to be below `0.0`.
/// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`.
/// ```dart
/// print(1.99999.ceilToDouble()); // 2.0
/// print(2.0.ceilToDouble()); // 2.0
/// print(2.00001.ceilToDouble()); // 3.0
/// print((-1.99999).ceilToDouble()); // -1.0
/// print((-2.0).ceilToDouble()); // -2.0
/// print((-2.00001).ceilToDouble()); // -2.0
/// ```
double ceilToDouble();
/// Returns the integer double value obtained by discarding any fractional
/// digits from `this`.
///
/// If this is already an integer valued double, including `-0.0`, or it is not
/// a finite value, the value is returned unmodified.
///
/// For the purpose of rounding, `-0.0` is considered to be below `0.0`.
/// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`, and
/// in the range `0.0 < d < 1.0` it will return 0.0.
/// ```dart
/// print(2.5.truncateToDouble()); // 2.0
/// print(2.00001.truncateToDouble()); // 2.0
/// print(1.99999.truncateToDouble()); // 1.0
/// print(0.5.truncateToDouble()); // 0.0
/// print((-0.5).truncateToDouble()); // -0.0
/// print((-1.5).truncateToDouble()); // -1.0
/// print((-2.5).truncateToDouble()); // -2.0
/// ```
double truncateToDouble();
/// Provide a representation of this [double] value.
///
/// The representation is a number literal such that the closest double value
/// to the representation's mathematical value is this [double].
///
/// Returns "NaN" for the Not-a-Number value.
/// Returns "Infinity" and "-Infinity" for positive and negative Infinity.
/// Returns "-0.0" for negative zero.
///
/// For all doubles, `d`, converting to a string and parsing the string back
/// gives the same value again: `d == double.parse(d.toString())` (except when
/// `d` is NaN).
String toString();