What is the max value of integer in dart?

后端 未结 2 1927
猫巷女王i
猫巷女王i 2021-02-20 05:42

I have looked everywhere but I couldnt find any information related to this topic. Also, Is there a java - like Long / BigDecimal datatype in dart?

相关标签:
2条回答
  • 2021-02-20 05:48

    Dart 2

    For dart2js generated JavaScript Pixel Elephants answer is still true.

    within the range -253 to 253

    Other execution platforms have fixed-size integers with 64 bits.

    The type BigInt was added to typed_data

    Since Dart 2.0 will switch to fixed-size integers, we also added a BigInt class to the typed_data library. Developers targeting dart2js can use this class as well. The BigInt class is not implementing num, and is completely independent of the num hierarchy.

    Dart 1

    There are also the packages
    - https://pub.dartlang.org/packages/bignum
    - https://pub.dartlang.org/packages/decimal

    0 讨论(0)
  • 2021-02-20 06:14

    That depends if you are running in the Dart VM or compiling to JavaScript.

    On the Dart VM an int is arbitrary precision and has no limit.

    When compiling to JavaScript you are actually using floating point numbers, since that is all that JavaScript supports. This means you are restricted to representing integers within the range -253 to 253

    0 讨论(0)
提交回复
热议问题