Skip to main content

2147483647 and my experience

I finished a project with a large database without any difficulty even when I tested I didn’t find any things hard to do or hard to understand. One day the client called me and asked me to check telephone field for a tables, apparently there was a problem with updating telephone field in the database. I checked and found that sometimes when I try to update the telephone number in return instead of saving the entered number it will saving another number (2147483647), I checked again and again and noticed that always it save the same number although I tried different numbers but same number in the database. mehdix 2147483647 I started for solve this problem by clearing all sessions and double checking my PHP and MySQL code but still same error. I remembered one of lecturer who was so cool but when someone asks a question almost definite he would reply “ask Dr. google”. I am sure he never read this post as once I sent him a link he didn’t click on that link, basically he never read such posts, I guess he only visit a few websites. Anyway come back to my problem, I searched this number in google(basically asked Dr. Google) and found something interesting which I didn’t know before: Wikipedia
The number 2,147,483,647 is the eighth Mersenne prime, equal to 231 − 1. It is one of only four known double Mersenne primes.
And
Euler ascertained that 231 − 1 = 2147483647 is a prime number; and this is the greatest at present known to be such, and, consequently, the last of the above perfect numbers [i.e., 230(231− 1)], which depends upon this, is the greatest perfect number known at present, and probably the greatest that ever will be discovered; for as they are merely curious, without being useful, it is not likely that any person will attempt to find one beyond it.
So as you may already guessed, I figured out what was wrong, telephone field in the database was int and limit was 11 digits. The problem is occurred when the telephone number is bigger the 2147483647, basically overflow condition happen here, well in reality we don’t have a telephone number which is bigger than 2147483647. 
As I always interested in Mathematics, this caused me to read more about such numbers which made story more fascinating

Popular posts from this blog

I solved GCHQ puzzle and this is how I did it

Today, I was reading the BBC news and I stumbled upon this GCHQ puzzle:
Take the digits 1,2,3 up to 9 in numerical order and put either a plus sign or a minus sign or neither between the digits to make a sum that adds up to 100. 

For example, one way of achieving this is: 1 + 2 + 34 - 5 + 67 - 8 + 9 = 100, which uses six plusses and minuses. What is the fewest number of plusses and minuses you need to do this?

I love to challenge myself with these kind of puzzles, so I solved this and here is how:

We have 9 numbers [1 to 9] and also we have three possible separators [+, - and nothing] which to fill the gap between numbers we have 8 combinations of separators, e.g. we have 1+2+3+4+5+6+7-89 which in this case we have six times plus, one minus and one time nothing.
So, I need to find all possibilities of combination which total is: 6561

Then, hook the possible combinations into numbers and check the total, easy enough. Now print the solution.

I have written this algorithm in PHP but easil…

The best way to predict the future is to create it

I am sure everyone knows the comfort of being on autopilot, less decision to make, apparently it's more reliable and with less potential mistakes as someone else tested and worked for them therefore it should be safe. but it is true?

But life is not that simple, although the easy way(for now) is to avoid thinking about it. To me at this points of the time (this may not be true in the future) life is a book which you need to write it so you write as you wish. You can write a sad story and make the main character a victim or write a happy story be a strong characters.


The best way to predict the future is to create it Abraham Lincoln or Peter Drucker or Alan Kay (don't matter who said it)

In summer 2016 I had an interview with a startup so few days before the interview date I was preparing myself for the interview and I came across this quote and made a note of it. When I entered the interview room, obviously I looked around the room and as my surprise I saw this frame hanging o…

Why I don't have social media account?

Just to be clear, I do not have any social media accounts except LinkedIn. No Facebook, Twitter, Instagram etc. 
I used to use some of them but I dropped them all before 2013 and now I am clean for over 4 years. I kept LinkedIn because I use for business contact only.
Today, I came cross this video and found quite interesting as I agree with what he says. 

I always said, the social media website/app specially Facebook and Instagram are just a game. It's funny how some users write the fake status which they don't believe it themselves but other believe it and vice versa. 
If you are making money or adding value to your life by using these apps, then use it otherwise don't kid yourself and just get rid of them, simply. I know it's hard in the beginning but trust me, it worth it, you are not alone.