The `toDouble` method of BigInt class in Dart converts a BigInt to a double.
The syntax of BigInt.toDouble() method is:
double toDouble()
This toDouble() method of BigInt returns this BigInt as a double.
BigInt.toDouble() returns value of type double
.
In this example,
num
, initialized with a large integer.toDouble
method to convert the BigInt to a double.void main() {
BigInt num = BigInt.parse('1234567895269666362');
double result = num.toDouble();
print('BigInt to double: $result');
}
BigInt to double: 1234567895269666300
In this example,
num
, initialized with another large integer.toDouble
method to convert the BigInt to a double.void main() {
BigInt num = BigInt.from(987654321);
double result = num.toDouble();
print('BigInt to double: $result');
}
BigInt to double: 987654321
In this example,
num
, initialized with a big integer.toDouble
method to convert the BigInt to a double.void main() {
BigInt num = BigInt.from(1000000000);
double result = num.toDouble();
print('BigInt to double: $result');
}
BigInt to double: 1000000000
In this Dart tutorial, we learned about toDouble() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.