Skip to content

toDouble() can throw exception due to issue in BigInt #16

Open

Description

@toddobryan

Try the following:

  BigDecimal bd = BigDecimal.parse("6.6880440087720299389e+806");
  print(bd.toDouble());

I get the following exception:

Unhandled exception:
Invalid argument(s): Exponent must not be negative: -787
#0      _BigIntImpl.pow (dart:core-patch/bigint_patch.dart:1872:7)
#1      BigDecimal.toDouble (package:big_decimal/src/big_decimal.dart:166:43)

It even fails if you change the e+806 to something as small as e+21.

Activity

  1. toddobryan commented on Dec 27, 2025

    @toddobryan
    ContributorAuthor

    OK. BigDecimal.parse("1e2").toDouble() throws the same exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions