Latest Articles
 by awuehr on 11-10-2008 in Tips & Tricks by Village Idiot on 11-04-2008 in Classes & Objects by codefreek on 10-23-2008 in Basic by wiifanatic on 09-12-2008 in Security & Permissions by drewbee on 07-03-2008 in Tips & Tricks
 IRC Channel
 Join the friendly bunch on IRC... (#TalkPHP on Freenode) ...Also available via a web interface. See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
 Associates
 Associates
 TalkPHP » another problem confuse me
 11-29-2008, 01:41 PM #1 (permalink) The Wanderer     Join Date: Nov 2008 Posts: 7 Thanks: 2 another problem confuse me hi,thank the guys solved my preceding puzzle. now I want to know that why the result of " intval(042); " is 34 but not 42,who can tell me ? thanks ,
 11-29-2008, 02:52 PM #2 (permalink) Moderateur          Join Date: Apr 2007 Posts: 1,393 Thanks: 5 The number `042` is an octal number (base 8) rather than a 'normal' decimal number (base 10). It's the octal `42` which can be explained below: Octal Code: ```32 16 8 1 - - 4 2``` To work out the decimal value, multiply the header line by the digit line and sum those values. `8*4 + 1*2` which gives 34. Compare this to decimal numbers Code: ```1000 100 10 1 - - 4 2``` Multiplying the values together again: `10*4 + 1*2` which gives 42. You can also use hexadecimal (base 16) by preceding the number with `0x`. For example, all of the following have an integer value of 123. PHP Code: ``` \$num = 123;  // decimal \$num = 0x7B; // hexadecimal \$num = 0173; // octal  ``` More information can be found on the integers PHP manual page.
The Wanderer

Join Date: Nov 2008
Posts: 7
Thanks: 2

Quote:
 Originally Posted by Salathe The number `042` is an octal number (base 8) rather than a 'normal' decimal number (base 10). It's the octal `42` which can be explained below: Octal Code: ```32 16 8 1 - - 4 2``` To work out the decimal value, multiply the header line by the digit line and sum those values. `8*4 + 1*2` which gives 34. Compare this to decimal numbers Code: ```1000 100 10 1 - - 4 2``` Multiplying the values together again: `10*4 + 1*2` which gives 42. You can also use hexadecimal (base 16) by preceding the number with `0x`. For example, all of the following have an integer value of 123. PHP Code: ``` \$num = 123;  // decimal \$num = 0x7B; // hexadecimal \$num = 0173; // octal  ``` More information can be found on the integers PHP manual page.
thank you very much.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On

 Similar Threads Thread Thread Starter Forum Replies Last Post Huge Session Problem Killswitch General 1 11-17-2008 02:36 AM Strange string comparison problem Jelmer General 0 05-23-2008 04:00 PM A serious curl checkbox problem bedri Advanced PHP Programming 1 05-22-2008 04:25 PM A bug or a cache problem?! yazid Advanced PHP Programming 0 05-22-2008 08:40 AM ÅÄÖ (charset=iso-8859-1) problem cthemaaan Advanced PHP Programming 6 03-28-2008 11:08 AM

All times are GMT. The time now is 03:50 PM.