search

Home  >  Q&A  >  body text

Why javascript 18014398501093363 == 18014398501093364 returns true

As the title, as shown in the picture

迷茫迷茫2819 days ago615

reply all(3)I'll reply

  • 欧阳克

    欧阳克2017-06-26 10:57:29

    In fact, sgf has an article that explains it in detail/a/11...; I also expanded the safe calculation range by the way, get!

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-26 10:57:29

    I tested it, 1801439850109336 == 1801439850109335 output is false, 18014398501093363 == 18014398501093364 is indeed true. So it should be that js can compare numbers with up to 16 digits, and any extra 16 digits will be rounded off at the end. If you must compare large numbers, you can convert the numbers into strings and determine whether the two strings are equal.

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-26 10:57:29

    Just found one

    reply
    0
  • Cancelreply