RE: [PHP-DEV] Octal numbers and automatic conversions

From: Date: Tue, 16 Jan 2001 15:51:35 +0000
Subject: RE: [PHP-DEV] Octal numbers and automatic conversions
Groups: php.dev 
Request: Send a blank email to php-dev+get-44241@lists.php.net to get a copy of this message
I remember this showing up years ago in an online java mortgage calculator giving embarrasingly far-out results. Only there the bug was the "other way round". In this case my opinion is that it is behaving as expected and no error. If the programmer writes 070 he probably means octal, but that doesn't mean every user and zero-padded string means octal. I hope the behaviour is not changed; or we may get bad mortage calculators again. Sam > -----Original Message----- > From: Sergio Bruder [mailto:bruder@conectiva.com.br] > Sent: Tuesday, January 16, 2001 02:01 > To: php-dev@lists.php.net > Subject: [PHP-DEV] Octal numbers and automatic conversions > > > This snippet shows what I consider a problem: The automatic conversion > string->integer doesnt interprets '070' as an octal, giving > 57 in the first > echo (correct) and 71 in the second (wrong). > > <? > echo (070 +1). "<BR>\n"; > echo ('070'+1). "<BR>\n"; > ?> > > Sergio Bruder > > -- > ( http://distro.conectiva.com.br > )) (tm) http://sergio.bruder.net > |""|-. http://pontobr.org > |__|-' bruder@conectiva.com.br, sergio@bruder.net > -------------------------------------------------------------- > ---------------- > pub 1024D/0C7D9F49 2000-05-26 Sergio Devojno Bruder > <bruder@conectiva.com.br> > Key fingerprint = 983F DBDF FB53 FE55 87DF 71CA 6B01 > 5E44 0C7D 9F49 > sub 1024g/138DF93D 2000-05-26 > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.dev (#44241) next »