For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > September 2006 > #38888 [Opn->Fbk]: gmp_init treats leading zero as octal









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #38888 [Opn->Fbk]: gmp_init treats leading zero as octal
bjori@php.net

2006-09-20, 3:58 am

ID: 38888
Updated by: bjori@php.net
Reported By: php at richardneill dot org
-Status: Open
+Status: Feedback
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:

What exactly gave you the impression it $i = 010; should
be 10?
IMO it is very well documented at php.net/integer and has
nothing to do GMP what so ever.

(I don't see your note anywhere..)


Previous Comments:
------------------------------------------------------------------------

[2006-09-19 23:57:22] php at richardneill dot org

Description:
------------
The documentation for gmp_init implies that a number will only be
parsed as hexadecimal if it begins with 0x, and decimal otherwise.

Thus: "10" means ten
"0x10" means sixteen
"010" means ten.

However, in practice, "010" is parsed as eight!.

Not sure whether this is a documentation bug, or an actual bug though.
Personally, I'd prefer "010" to mean ten, but I am aware of some
conventions in which it means octal.

Confusingly:
$x=010 //$x is eight
$x="010" //$x is ten


Please also correct the comment I added to the gmp_init page - I said
that it 010 was parsed as hex, when I meant octal.



------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=38888&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com