.toDouble()
Anonymous contributor
Published May 20, 2024
Contribute to Docs
In Dart, the .toDouble()
method is used to convert numeric data types, such as int
, to their corresponding double-precision floating-point representation.
Syntax
numericValue.toDouble();
numericValue
: Represents the variable to be converted todouble
.
Example
The following example demonstrates how to use the .toDouble()
method to convert an integer to a double
:
void main() {int number = 3;double value = number.toDouble();print("Output = ${value}");}
The above code produces the following output:
Output = 3.0
Note: The output 3.0 is a
double
. This can be confirmed by checkingvalue.runtimeType
.
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.