truncate method

int truncate()

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).

print(Obj(2.00001).truncate()); // 2
print(Obj(1.99999).truncate()); // 1
print(Obj(0.5).truncate()); // 0
print(Obj(-0.5).truncate()); // 0
print(Obj(-1.5).truncate()); // -1
print(Obj(-2.5).truncate()); // -2

Implementation

int truncate() => value.truncate();