TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble 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
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-29-2008, 01:41 PM   #1 (permalink)
The Wanderer
 
kuigg's Avatar
 
Join Date: Nov 2008
Posts: 7
Thanks: 2
kuigg is on a distinguished road
Default 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 ,
kuigg is offline  
Reply With Quote
Old 11-29-2008, 02:52 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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.
Salathe is offline  
Reply With Quote
Old 11-29-2008, 03:56 PM   #3 (permalink)
The Wanderer
 
kuigg's Avatar
 
Join Date: Nov 2008
Posts: 7
Thanks: 2
kuigg is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
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.
kuigg is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

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 Off
Trackbacks 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 06:51 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design