The `roundToDouble` method in Dart returns the double representation of this integer.
The syntax of int.roundToDouble() method is:
double roundToDouble()
This roundToDouble() method of int returns this.toDouble().
int.roundToDouble() returns value of type double
.
In this example,
5
to the integer variable num1
.num1
to a double using the roundToDouble()
method.void main() {
int num1 = 5;
double doubleNum1 = num1.roundToDouble();
print('Double value of $num1: $doubleNum1');
}
Double value of 5: 5
In this example,
-3
to the integer variable num2
.num2
to a double using the roundToDouble()
method.void main() {
int num2 = -3;
double doubleNum2 = num2.roundToDouble();
print('Double value of $num2: $doubleNum2');
}
Double value of -3: -3
In this example,
10
to the integer variable num3
.num3
to a double using the roundToDouble()
method.void main() {
int num3 = 10;
double doubleNum3 = num3.roundToDouble();
print('Double value of $num3: $doubleNum3');
}
Double value of 10: 10
In this Dart tutorial, we learned about roundToDouble() method of int: the syntax and few working examples with output and detailed explanation for each example.