Dart Programming - truncate Method



Returns an integer after discarding any fractional digits.

Syntax

Number.truncate()

Return Value

Returns an int without decimal points.

Example

void main() { 
   double n1 = 2.123; 
   var value = n1.truncate(); 
   print("The truncated value of 2.123 = ${value}"); 
} 

It will produce the following output −.

The truncated value of 2.123 = 2 
dart_programming_numbers.htm
Advertisements