0

I need to parse a String with 18 decimal values to double, but it seems double only support 14 decimal values.

For example: “15.123456789101112131”

3
  • 1
    Check out this arbitrary precision floating point impl: pub.dev/documentation/quantity/latest/number/Precise-class.html Commented Jan 31, 2022 at 13:25
  • 1
    The double type is a binary floating-point type, so storing a specific number of decimal digits is a bit nonsensical. If you want to store a specific number of decimal digits, use a type appropriate for that, such as the Precise class mentioned above or package:decimal. Commented Jan 31, 2022 at 19:40
  • Thank you, RichardHeap and jamesdlin, for replying to my question; your answer was helpful. Commented Feb 7, 2022 at 10:52

1 Answer 1

1
Precise(
       String value,
       {int sigDigits = 50}
)

Constructs an arbitrary precision number from a string.

The precision can be limited by providing the maximum number of significant digits (default is 50).

Examples: Precise('12') Precise('0.1234') Precise('15.123456789101112131') Precise('1.23456789e-6', sigDigits: 4)

Precise constructor

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.