Dart num toDouble()
Syntax & Examples
num.toDouble() method
The `toDouble` method in Dart converts this num to a double.
Syntax of num.toDouble()
The syntax of num.toDouble() method is:
 double toDouble() This toDouble() method of num return this num as a double.
Return Type
num.toDouble() returns value of type  double.
✐ Examples
1 Converting an integer to double
In this example,
- We create a num variable 
num1with the value 4. - We use the 
toDouble()method to convert it to a double. - We then print the result to standard output.
 
Dart Program
void main() {
  num num1 = 4;
  double doubleValue = num1.toDouble();
  print('Double value of $num1: $doubleValue');
}Output
Double value of 4: 4
2 Converting a decimal number to double
In this example,
- We create a num variable 
num1with the value 3.14. - We use the 
toDouble()method to convert it to a double. - We then print the result to standard output.
 
Dart Program
void main() {
  num num1 = 3.14;
  double doubleValue = num1.toDouble();
  print('Double value of $num1: $doubleValue');
}Output
Double value of 3.14: 3.14
3 Converting a negative integer to double
In this example,
- We create a num variable 
num1with the value -10. - We use the 
toDouble()method to convert it to a double. - We then print the result to standard output.
 
Dart Program
void main() {
  num num1 = -10;
  double doubleValue = num1.toDouble();
  print('Double value of $num1: $doubleValue');
}Output
Double value of -10: -10.0
Summary
In this Dart tutorial, we learned about toDouble() method of num: the syntax and few working examples with output and detailed explanation for each example.