The `truncateToDouble` method returns the integer double value obtained by discarding any fractional digits from the given double.
The syntax of double.truncateToDouble() method is:
double truncateToDouble()
This truncateToDouble() method of double returns the integer double value obtained by discarding any fractional digits from this
.
double.truncateToDouble() returns value of type double
.
In this example,
num
with a value of 3.14
.truncateToDouble()
method on num
to obtain its truncated value.void main() {
double num = 3.14;
double truncated = num.truncateToDouble();
print('Truncated value of 3.14: $truncated');
}
Truncated value of 3.14: 3
In this example,
num
with a value of -5.6
.truncateToDouble()
method on num
to obtain its truncated value.void main() {
double num = -5.6;
double truncated = num.truncateToDouble();
print('Truncated value of -5.6: $truncated');
}
Truncated value of -5.6: -5
In this example,
num
with a value of 10.9
.truncateToDouble()
method on num
to obtain its truncated value.void main() {
double num = 10.9;
double truncated = num.truncateToDouble();
print('Truncated value of 10.9: $truncated');
}
Truncated value of 10.9: 10
In this Dart tutorial, we learned about truncateToDouble() method of double: the syntax and few working examples with output and detailed explanation for each example.