Jump to content

Parameter passing incorrectly


phpknight

Recommended Posts

Hi,

 

I'm using Ajax with PHP and Javascript. I pass a function this number: 00000000000001525553.  But when it gets there, it is this: 437099.  PHP is processing it correctly, but Javascript is not.

 

I fixed it by putting the number in single quotes as a single.  However, I don't get why it messed up.

 

What is happening here?  Overflow?  Are my padded zeros creating a problem? Is it doing an incorrect typecast?

 

I'd like to know the cause of the problem.  Thanks!

Link to comment
https://forums.phpfreaks.com/topic/163436-parameter-passing-incorrectly/
Share on other sites

Acording to the rules of integers syntax http://php.net/manual/en/language.types.integer.php, numbers  in format of 0[0-9]+ are considered in octal.

 

So intval(00000000000001525553) is being parsed as

 

From right to left...

3*(8^0) + 5*(8^1) + ... the rest we know.. which gives the magical number of 437099.

 

Have a nice day!  8)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.