Convert exponential number to numeric Dart

Viewed 379

How can I convert exponential numbers to numeric? For example, I have 4.903381641568837e-7 and want to convert it to 0.00000049034...

1 Answers

You should try the decimal package :

    import 'package:decimal/decimal.dart';

    void main() {
      double smallDouble = 0.0000000000000024353505535353555;

      final convertedDouble = Decimal.parse(smallDouble.toString());

      print("normal double :>> $smallDouble");
      print("Decimal :>> $convertedDouble");
    }

Output:

normal double :>> 2.4353505535353554e-15
Decimal :>> 0.0000000000000024353505535353554

Hope it could help.

Related