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 

5 comments:

  1. This comment has been removed by the author.

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

    ReplyDelete

Share your thoughts

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