JavaScript’s Defects on Numbers

Number larger than 0x20000000000000 (54bit) will not be reliable.

Here is the test script:

javascript:alert (0x1ffffffffffffe);
javascript:alert (0x1fffffffffffff);
javascript:alert (0x20000000000000);
javascript:alert (0x20000000000001);

You can see that the latter two numbers are same number in JavaScript!


The safe number range for integer is “-0x1fffffffffffff – 0x1fffffffffffff” (53bit). Therefore, in Java to JavaScript world, conversion of Java’s long number to JavaScript’s Number may result in incorrect calculations.

This entry was posted in JavaScript. Bookmark the permalink.

29 Responses to JavaScript’s Defects on Numbers

  1. I won’t debate along with your conclusions simply I feel you are exact on the money! You’ve come up with a valid case for your sentiments and now I know much more this unusual subject. Thank you this outstanding publish and that i will arrive again for additional.

  2. Chris says:

    That would be because all numbers in javascript are actually 64 bit floating point.
    Not all integers higher than 53 bits can be exactly represented as a 64 bit floating point value, hence 0x20000000000000 and 0x20000000000001 are the same.
    This is due to the 11 bit exponent and the 1 sign bit. This only leaves 52 bits to store the fraction

  3. First, let me commend your pellucidity on this subject. I am not a pro during this subject, but after reading your write-up, my knowledge has developed substantially. Please tolerate me to catch your rss nourish to remain in contact with any upcoming revisions. Pleasant career and will offer it on to pals and my weblog audience.

  4. gry dzieci says:

    Super witryna. Oby tak dalej.

  5. Your thought is not incorrect,I am guessing God helps those who aid themselves. Come on!

  6. Earlean Metzinger says:

    Nowadays to find a similar Efficient and Effective SEO Automation software at one Time payment of US 99-00 is a rarity\

  7. Hi there, just wanted to mention, I loved this article. It was inspiring.
    Keep on posting!

    Feel free to surf to my web blog: milwaukee Car accident attorney

  8. Hey there, I think your website might be having browser compatibility
    issues. When I look at your blog in Opera, it looks fine but when opening in Internet Explorer, it has some
    overlapping. I just wanted to give you a quick heads up!
    Other then that, great blog!

    Feel free to visit my web page – auto accident attorney fort lauderdale

  9. Since the popularity of saltwater fly fishing has increased over the past years, bonefish anglers from around the world are captivated by the Republic of Kiribati.
    Breathing dirty air, no matter how cool that
    air is, can cause health problems. The Suzuki
    Swift entered the American market for the 1989 model year.

  10. Utilizing the created free Crystal it is going to be attainable to principally unlock and shopping for anything within Star Wars Force Collection totally free.

  11. Within the simply mean interval let us take a look beneath
    to obtain cool money cheats and useful suggestions.

  12. BATTLE BEARS GOLD is an award profitable multiplayer motion app for Android and iOS gadgets like iPhone, iPad, iPod Contact and iPad Mini.

  13. One SIM card vulnerability and some hacks
    later, the possibly deadly remote takeover flaw went from being a theoretical assault to
    a believable threat.

  14. Natasha says:

    But the perfect a part of human enticing place usually
    that Pixel Firearm 3d fashions get into has now per day news.

  15. Bidoo coughing resources are recognized for supplying the help that was greatest hacking.

  16. The most effective hack has to work on all the mobiles, ought to work faster, limitless properly being,
    infinite gold and infinite money.

  17. it’s good to read this web site,The most effective hack has to work on all the mobiles.

  18. sell land says:

    thank you, this post.

  19. thank you, this post the good.

  20. You’ve gotten great thing listed here

  21. 今日は よろしくお願いしますね^^すごいですね^^
    銈般儍銉?銉栥儸銈广儸銉冦儓 338798-J8980/8131 銉栥儵銉冦偗 銉?偠銉?绶ㄣ伩杈笺伩銉?偠銉? GUCCI 銆怸DKG-tk銆戙?愩伅銇撱伣銇欏?蹇滃晢鍝併?戙?愩偝銉炽儞銉嬪彈鍙栧?蹇滃晢鍝併?戙?怋OX鍙楀彇瀵捐薄鍟嗗搧銆憒銈般儍銉?銉栥儸銈广儸銉冦儓 338798-J8980/8131 銉栥儵銉冦偗 銉?偠銉?绶ㄣ伩杈笺伩銉?偠銉? G

  22. Thanks, this website is extremely handy

  23. Great little shoe charm, fast shipping, thanks!!

  24. nba 2k says:

    Just had to mention Now i am lucky I happened on the website!.

  25. Eduardo says:

    You really make it appear really easy along with your presentation but I in finding this topic to be
    actually something thbat Ithink I might never understand. It sort of feels too complex and very huge for me.
    I am haaving a look ahead for your subsequent submit, I will attempt to get the hold of it!

  26. This is my first time visit at here and i am really impressed
    to rad all at alone place.

  27. Unquestionably consider that which you said.
    Your favorite justification appeared to be at the web the easiest thing to take into accout of.
    I say to you, I certainly get irked while other
    people consider issues that they plainly don’t understand about.

    You controlled to hit the nail upon the top and defined out the entire thing with no need side effect , other people could take a
    signal. Will likely be back to get more. Thanks

  28. The "storm" when it comes to livestock is I don’t think you really thought your position out very

  29. OonewEmams says: Вы можете посмотреть видео бесплатно и без регистрации. Очень прикольно вы согласны?

Leave a Reply

Your email address will not be published. Required fields are marked *