Wednesday, September 3, 2014

9223372036854775807 is a special number

The number 9223372036854775807 is a very special number in programming but why?

Take a look at this small program in .NET, I have declared a long integer and saved this number in it.




I will now increase this number by 1 and try to store it. I will try to store the 9223372036854775808 number Note the compile error I got in this code.



The reason it overflowed is because n is a signed long integer variable, which means it is a 64 bit number. This means it can hold up to 2^63 -1 only and the computer cannot store the extra number.


Avoid Overflows! Make sure your calculations doesn't exceed this number in your future code!

Want to learn programming and software engineering? Follow my YouTube Channel 

9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. The article is very interesting and very understood to be read, may be useful for the people. I wanted to thank you for this great read!! I definitely enjoyed every little bit of it. I have to bookmarked to check out new stuff on your post. Thanks for sharing the information keep updating, looking forward for more posts..
    Kindly visit us @
    Madurai Travels | Travels in Madurai
    Best Travels in Madurai
    Cabs in Madurai | Madurai Cabs
    Tours and Travels in Madurai

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete

Share your thoughts

Note: Only a member of this blog may post a comment.