Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-29 Thread Alexander Skwar
So sprach 1LT John W. Holmes am 2003-01-27 um 15:49:33 -0500 :
 Actually, 08 is equal to 8 in PHP. PHP will convert the string to an

No, that's not true:

if (08 == 8){ echo equal; }
if (08 === 8){ echo more equal; }

This will only print equal and not more equal.

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.iso-top.biz |Jabber: [EMAIL PROTECTED]
   iso-top.biz - Die günstige Art an Linux Distributionen zu kommen
   Uptime: 1 day 15 hours 46 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-29 Thread Chris Shiflett
--- Alexander Skwar [EMAIL PROTECTED] wrote:
 So sprach 1LT John W. Holmes am 2003-01-27 um 15:49:33
 -0500 :
  Actually, 08 is equal to 8 in PHP. PHP will convert
  the string to an
 
 No, that's not true:
 
 if (08 == 8){ echo equal; }
 if (08 === 8){ echo more equal; }
 
 This will only print equal and not more equal.

Good thing he didn't say they were more equal, right?

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-28 Thread Maxim Maletsky
just try doing it with === (three equal signs) and you'll see what is
where


--
Maxim Maletsky
[EMAIL PROTECTED]



Cal Evans [EMAIL PROTECTED] wrote... :

 John.
 
  Actually, 08 is equal to 8 in PHP. PHP will convert the string to an
 integer and the two will compare as equal.
 
 No they are not equal. Yes, PHP will do the conversion so that they are
 equal. That does not refute the fact that logically '08' != 8.
 
 
  Someone already posted why the problem was happening, because the numbers
  were being converted to invalid octal numbers and being set to zero.
 
 I understand the problem at hand. (and did when I posted) However, if Scott
 had been doing the conversions manually, he would never have run across this
 problem.  It is a bad idea to rely on the language (whatever the language)
 to do automatic variable conversions.
 
 =C=
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-28 Thread Maxim Maletsky

Your bug is this:

inconsistency of types.

You split a formatted string into smaller strings and compare the
integers to it. In order to do this correctly, you will need to take
your integers and convert them into the strings, format of which you
already know and used for deformatting the original string. Then compare.

That is the only way to be safe, other ways are magic because PHP
debugged them for you. It's really all about the programming logic. few
of you who are fluent with C or Java would dump into this.


--
Maxim Maletsky
[EMAIL PROTECTED]



Scott Fletcher [EMAIL PROTECTED] wrote... :

 Found a PHP bug, I'm using PHP version 4.2.3.  I have been struggling with
 why PHP code failed to work with the month is August or September, so I have
 been playing around it and found the problem.  I recently wrote a demo
 script for you all to play around with.  Let me know which PHP version does
 this bug not affected you  I'm going to file a PHP bug at
 http://bug.php.net..  I'll let you know where PHP bug # is it.  To tell
 you the truth, I don't know how to search for existing bug on this one if
 there is any because I don't know if it is an if-statement issue or if it is
 something else  Feel free to submit a patch if you know how.
 
 Let me know what you found and post it here...
 
 --clip--
 ?
//Sample Code. ==
$VARIABLE[0] = 2002-01;
$VARIABLE[1] = 2002-02;
$VARIABLE[2] = 2002-03;
$VARIABLE[3] = 2002-04;
$VARIABLE[4] = 2002-05;
$VARIABLE[5] = 2002-06;
$VARIABLE[6] = 2002-07;
$VARIABLE[7] = 2002-08;
$VARIABLE[8] = 2002-09;
$VARIABLE[9] = 2002-10;
$VARIABLE[10] = 2002-11;
$VARIABLE[11] = 2002-12;
 
//Loop Code to check the variable ===
for ($x=0;$x12;$x++) {
   $month = substr($VARIABLE[$x],5,2);
 
   echo The # of month is .$x.br;
 
   if ($month == 01) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 02) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 03) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 04) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 05) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 06) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 07) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 08) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 09) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 10) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 11) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
   if ($month == 12) { echo It's a Match!!br; } else { echo It's not
 a Match!!br; }
 
   echo br;
}
 
//Strange Workaround to 08 and 09 ===
echo Strange Workaround to the Problem!!brbr;
 
$month = substr($VARIABLE[7],5,2);
echo The # of month is 08br;
if (trim($month) == 8) {
   echo It's working!!!br;
}
 
$month = substr($VARIABLE[8],5,2);
echo The # of month is 09br;
if (trim($month) == 9) {
   echo It's working!!!br;
}
 
//Testing (Should this be working or not??) =
echo brbr;
$month = substr($VARIABLE[0],5,2);
echo The # of month is 1br;
if (trim($month) == 1) { //With 1 as an integer...
   echo It's working!!!br;
}
 
echo br;
$month = substr($VARIABLE[0],5,2);
echo The # of month is 01br;
if (trim($month) == 01) { //With 01 as an integer
   echo It's working!!!br;
}
 
echo br;
$month = substr($VARIABLE[0],5,2);
echo The # of month is 1br;
if (trim($month) == 1) { //With 1 as an integer...
   echo It's working!!!br;
}
 
echo br;
$month = substr($VARIABLE[0],5,2);
echo The # of month is 01br;
if (trim($month) == 01) { //With 01 as an integer
   echo It's working!!!br;
}
 ?
 --clip--
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Found a PHP bug, I'm using PHP version 4.2.3.  I have been struggling with
why PHP code failed to work with the month is August or September, so I have
been playing around it and found the problem.  I recently wrote a demo
script for you all to play around with.  Let me know which PHP version does
this bug not affected you  I'm going to file a PHP bug at
http://bug.php.net..  I'll let you know where PHP bug # is it.  To tell
you the truth, I don't know how to search for existing bug on this one if
there is any because I don't know if it is an if-statement issue or if it is
something else  Feel free to submit a patch if you know how.

Let me know what you found and post it here...

--clip--
?
   //Sample Code. ==
   $VARIABLE[0] = 2002-01;
   $VARIABLE[1] = 2002-02;
   $VARIABLE[2] = 2002-03;
   $VARIABLE[3] = 2002-04;
   $VARIABLE[4] = 2002-05;
   $VARIABLE[5] = 2002-06;
   $VARIABLE[6] = 2002-07;
   $VARIABLE[7] = 2002-08;
   $VARIABLE[8] = 2002-09;
   $VARIABLE[9] = 2002-10;
   $VARIABLE[10] = 2002-11;
   $VARIABLE[11] = 2002-12;

   //Loop Code to check the variable ===
   for ($x=0;$x12;$x++) {
  $month = substr($VARIABLE[$x],5,2);

  echo The # of month is .$x.br;

  if ($month == 01) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 02) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 03) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 04) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 05) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 06) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 07) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 08) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 09) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 10) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 11) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }
  if ($month == 12) { echo It's a Match!!br; } else { echo It's not
a Match!!br; }

  echo br;
   }

   //Strange Workaround to 08 and 09 ===
   echo Strange Workaround to the Problem!!brbr;

   $month = substr($VARIABLE[7],5,2);
   echo The # of month is 08br;
   if (trim($month) == 8) {
  echo It's working!!!br;
   }

   $month = substr($VARIABLE[8],5,2);
   echo The # of month is 09br;
   if (trim($month) == 9) {
  echo It's working!!!br;
   }

   //Testing (Should this be working or not??) =
   echo brbr;
   $month = substr($VARIABLE[0],5,2);
   echo The # of month is 1br;
   if (trim($month) == 1) { //With 1 as an integer...
  echo It's working!!!br;
   }

   echo br;
   $month = substr($VARIABLE[0],5,2);
   echo The # of month is 01br;
   if (trim($month) == 01) { //With 01 as an integer
  echo It's working!!!br;
   }

   echo br;
   $month = substr($VARIABLE[0],5,2);
   echo The # of month is 1br;
   if (trim($month) == 1) { //With 1 as an integer...
  echo It's working!!!br;
   }

   echo br;
   $month = substr($VARIABLE[0],5,2);
   echo The # of month is 01br;
   if (trim($month) == 01) { //With 01 as an integer
  echo It's working!!!br;
   }
?
--clip--



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Jason Wong
On Tuesday 28 January 2003 03:56, Scott Fletcher wrote:
 Found a PHP bug, I'm using PHP version 4.2.3.  I have been struggling with
 why PHP code failed to work with the month is August or September, so I
 have been playing around it and found the problem.  I recently wrote a demo
 script for you all to play around with.  Let me know which PHP version does
 this bug not affected you  I'm going to file a PHP bug at
 http://bug.php.net..  I'll let you know where PHP bug # is it.  To tell
 you the truth, I don't know how to search for existing bug on this one if
 there is any because I don't know if it is an if-statement issue or if it
 is something else  Feel free to submit a patch if you know how.

 Let me know what you found and post it here...

 --clip--

[snip]

   if ($month == 01) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 02) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 03) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 04) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 05) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 06) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 07) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 08) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }
   if ($month == 09) { echo It's a Match!!br; } else { echo It's
 not a Match!!br; }


Have a look at the manual  Types  Integers

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
I'm having a BIG BANG THEORY!!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Johnson, Kirk

 -Original Message-
 From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
 
 Found a PHP bug, I'm using PHP version 4.2.3.  I have been 
 struggling with
 why PHP code failed to work with the month is August or 
 September

I stumbled into this one a short while ago myself. It is not a bug, but a
feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP interprets
them as octal numbers (because of the leading 0). However, 08 and 09 are
invalid octal numbers, so PHP converts them to zero.

The fixes are numerous:
 - remove the leading zero;
 - add zero to them before passing (addition forces a type conversion to
int);
 - force a type conversion to integer using (int);
 - quote them (when PHP converts a string to an integer, it removes the
leading zero);

Kirk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
I don't see why a string wouldn't work when I use 08 (string) and match it
against the integer 8, or 08.


Kirk Johnson [EMAIL PROTECTED] wrote in message
B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...

  -Original Message-
  From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
 
  Found a PHP bug, I'm using PHP version 4.2.3.  I have been
  struggling with
  why PHP code failed to work with the month is August or
  September

 I stumbled into this one a short while ago myself. It is not a bug, but a
 feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP interprets
 them as octal numbers (because of the leading 0). However, 08 and 09 are
 invalid octal numbers, so PHP converts them to zero.

 The fixes are numerous:
  - remove the leading zero;
  - add zero to them before passing (addition forces a type conversion to
 int);
  - force a type conversion to integer using (int);
  - quote them (when PHP converts a string to an integer, it removes the
 leading zero);

 Kirk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 Found a PHP bug
...
 if ($month == 01)

I guess you mean:

if ($month == '01')

If so, this is not a bug. Otherwise, please explain what
you think is wrong.

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Cal Evans
Scott,

Because 8 != 8. 8 (and 08) is a string with the numerals representing
the number eight. It is not the number eight. (think back to basic math, the
difference between a number and a numeral)

PHP does some conversions for you automatically but that just saves you from
yourself. (Personally, I wish it wouldn't. People have more trouble
*because* of the automatic conversions than they would if they had to do the
converting themselves.)

To keep from running into this simply do the conversions yourself before you
do comparisons.

intval(08)==8

=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 2:14 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Found a PHP bug!


I don't see why a string wouldn't work when I use 08 (string) and match it
against the integer 8, or 08.


Kirk Johnson [EMAIL PROTECTED] wrote in message
B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...

  -Original Message-
  From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
 
  Found a PHP bug, I'm using PHP version 4.2.3.  I have been
  struggling with
  why PHP code failed to work with the month is August or
  September

 I stumbled into this one a short while ago myself. It is not a bug, but a
 feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP interprets
 them as octal numbers (because of the leading 0). However, 08 and 09 are
 invalid octal numbers, so PHP converts them to zero.

 The fixes are numerous:
  - remove the leading zero;
  - add zero to them before passing (addition forces a type conversion to
 int);
  - force a type conversion to integer using (int);
  - quote them (when PHP converts a string to an integer, it removes the
 leading zero);

 Kirk



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Chris Hayes

Re: [PHP] Found a PHP bug!
uh oh...



I don't see why a string wouldn't work when I use 08 (string) and match it
against the integer 8, or 08.


They're just different types. Normally PHP is veeery flexible with 
types,  like javascript, but it just can't be flexible for you here because 
it needs to choose the most logic to the entire pool of programmers, and then
08 = a string
  8 = a decimal integer
 08 = by definition an impossible octal integer, so 0.

Since you cannot tell PHP that $var is of a certain type like in [other] 
programming languages, for example you want it to be treated as an integer, 
PHP will handle it as what seems to be the most logic.


You can try to use intval (does not alter a variable, only the value as it 
is used in a calculation or an if() statement) or settype (alters the 
variable).



Kirk Johnson [EMAIL PROTECTED] wrote in message
B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...

  -Original Message-
  From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
 
  Found a PHP bug, I'm using PHP version 4.2.3.  I have been
  struggling with
  why PHP code failed to work with the month is August or
  September

 I stumbled into this one a short while ago myself. It is not a bug, but a
 feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP interprets
 them as octal numbers (because of the leading 0). However, 08 and 09 are
 invalid octal numbers, so PHP converts them to zero.

 The fixes are numerous:
  - remove the leading zero;
  - add zero to them before passing (addition forces a type conversion to
 int);
  - force a type conversion to integer using (int);
  - quote them (when PHP converts a string to an integer, it removes the
 leading zero);

 Kirk



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
I'm referring to '08' and '09' that don't work

Chris Shiflett [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 --- Scott Fletcher [EMAIL PROTECTED] wrote:
  Found a PHP bug
 ...
  if ($month == 01)

 I guess you mean:

 if ($month == '01')

 If so, this is not a bug. Otherwise, please explain what
 you think is wrong.

 Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
I do know that integer, string, double, float, etc  are different..  I
have been using hte appropriate method like in javascript and c programming,
like converting it to integer and so on  But when I start using PHP, I
find no such document of it and I have been using it for 3 years without a
problem.  I asked people is there such a thing as converting it by using the
function and they told me there is no such a thing and that it is done
automatically...  Now my time is a little bit wasted.   So, I will correct
the problem with the php script...

I recently looked up on the manual as Jason Wong instructed me to.  I
havne't found the answer since the document is a little bit mixed up.

Okay, I'm going back to my old way as I did in javascript and c programming.
So for php, it would be

floatval() for float...
strval() for string
settype() for whatever..
intval() for integer

Um, what about double???

Thanks,
 Scott F.

Chris Hayes [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  Re: [PHP] Found a PHP bug!
 uh oh...


 I don't see why a string wouldn't work when I use 08 (string) and match
it
 against the integer 8, or 08.

 They're just different types. Normally PHP is veeery flexible with
 types,  like javascript, but it just can't be flexible for you here
because
 it needs to choose the most logic to the entire pool of programmers, and
then
 08 = a string
8 = a decimal integer
   08 = by definition an impossible octal integer, so 0.

 Since you cannot tell PHP that $var is of a certain type like in [other]
 programming languages, for example you want it to be treated as an
integer,
 PHP will handle it as what seems to be the most logic.


 You can try to use intval (does not alter a variable, only the value as it
 is used in a calculation or an if() statement) or settype (alters the
 variable).



 Kirk Johnson [EMAIL PROTECTED] wrote in message
 B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...
  
-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
   
    Found a PHP bug, I'm using PHP version 4.2.3.  I have been
struggling with
why PHP code failed to work with the month is August or
September
  
   I stumbled into this one a short while ago myself. It is not a bug,
but a
   feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP
interprets
   them as octal numbers (because of the leading 0). However, 08 and 09
are
   invalid octal numbers, so PHP converts them to zero.
  
   The fixes are numerous:
- remove the leading zero;
- add zero to them before passing (addition forces a type conversion
to
   int);
- force a type conversion to integer using (int);
- quote them (when PHP converts a string to an integer, it removes
the
   leading zero);
  
   Kirk
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Whoop!  FOund it,  it is doubleval()...


What does settype() do exactly


Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I do know that integer, string, double, float, etc  are different..  I
 have been using hte appropriate method like in javascript and c
programming,
 like converting it to integer and so on  But when I start using PHP, I
 find no such document of it and I have been using it for 3 years without a
 problem.  I asked people is there such a thing as converting it by using
the
 function and they told me there is no such a thing and that it is done
 automatically...  Now my time is a little bit wasted.   So, I will correct
 the problem with the php script...

 I recently looked up on the manual as Jason Wong instructed me to.  I
 havne't found the answer since the document is a little bit mixed up.

 Okay, I'm going back to my old way as I did in javascript and c
programming.
 So for php, it would be

 floatval() for float...
 strval() for string
 settype() for whatever..
 intval() for integer

 Um, what about double???

 Thanks,
  Scott F.

 Chris Hayes [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
   Re: [PHP] Found a PHP bug!
  uh oh...
 
 
  I don't see why a string wouldn't work when I use 08 (string) and
match
 it
  against the integer 8, or 08.
 
  They're just different types. Normally PHP is veeery flexible with
  types,  like javascript, but it just can't be flexible for you here
 because
  it needs to choose the most logic to the entire pool of programmers, and
 then
  08 = a string
 8 = a decimal integer
08 = by definition an impossible octal integer, so 0.
 
  Since you cannot tell PHP that $var is of a certain type like in [other]
  programming languages, for example you want it to be treated as an
 integer,
  PHP will handle it as what seems to be the most logic.
 
 
  You can try to use intval (does not alter a variable, only the value as
it
  is used in a calculation or an if() statement) or settype (alters the
  variable).
 
 
 
  Kirk Johnson [EMAIL PROTECTED] wrote in message
  B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...
   
 -Original Message-
 From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
    
 Found a PHP bug, I'm using PHP version 4.2.3.  I have been
 struggling with
 why PHP code failed to work with the month is August or
 September
   
I stumbled into this one a short while ago myself. It is not a bug,
 but a
feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP
 interprets
them as octal numbers (because of the leading 0). However, 08 and 09
 are
invalid octal numbers, so PHP converts them to zero.
   
The fixes are numerous:
 - remove the leading zero;
 - add zero to them before passing (addition forces a type
conversion
 to
int);
 - force a type conversion to integer using (int);
 - quote them (when PHP converts a string to an integer, it removes
 the
leading zero);
   
Kirk
  
  
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
I would need to use intval() to solve this problem

Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm referring to '08' and '09' that don't work

 Chris Shiflett [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  --- Scott Fletcher [EMAIL PROTECTED] wrote:
   Found a PHP bug
  ...
   if ($month == 01)
 
  I guess you mean:
 
  if ($month == '01')
 
  If so, this is not a bug. Otherwise, please explain what
  you think is wrong.
 
  Chris





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Ray Hunter
U might want to do a type cast to integer from string...

http://www.php.net/manual/en/language.types.type-juggling.php


On Mon, 2003-01-27 at 13:47, Scott Fletcher wrote:
 I would need to use intval() to solve this problem
 
 Scott Fletcher [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm referring to '08' and '09' that don't work
 
  Chris Shiflett [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   --- Scott Fletcher [EMAIL PROTECTED] wrote:
    Found a PHP bug
   ...
if ($month == 01)
  
   I guess you mean:
  
   if ($month == '01')
  
   If so, this is not a bug. Otherwise, please explain what
   you think is wrong.
  
   Chris
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread 1LT John W. Holmes
 Because 8 != 8. 8 (and 08) is a string with the numerals
representing
 the number eight. It is not the number eight. (think back to basic math,
the
 difference between a number and a numeral)

Actually, 08 is equal to 8 in PHP. PHP will convert the string to an
integer and the two will compare as equal.

 PHP does some conversions for you automatically but that just saves you
from
 yourself. (Personally, I wish it wouldn't. People have more trouble
 *because* of the automatic conversions than they would if they had to do
the
 converting themselves.)

Someone already posted why the problem was happening, because the numbers
were being converted to invalid octal numbers and being set to zero.

Run this bit of code for an example:

   echo br . ((01 == 1) ? Match : No Match);
   echo br . ((02 == 2) ? Match : No Match);
   echo br . ((03 == 3) ? Match : No Match);
   echo br . ((04 == 4) ? Match : No Match);
   echo br . ((05 == 5) ? Match : No Match);
   echo br . ((06 == 6) ? Match : No Match);
   echo br . ((07 == 7) ? Match : No Match);
   echo br . ((08 == 8) ? Match : No Match);
   echo br . ((09 == 9) ? Match : No Match);

The last two won't match because 08 and 09 are invalid octal numbers, like
Kirk Johnson already said.

So 08 != 08 and 8 != 08, for example.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Leif K-Brooks
No, it's floatval.  Doubleval is an alias left over from hwen floats 
were called doubles...

Scott Fletcher wrote:

Whoop!  FOund it,  it is doubleval()...


What does settype() do exactly


Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 

I do know that integer, string, double, float, etc  are different..  I
have been using hte appropriate method like in javascript and c
   

programming,
 

like converting it to integer and so on  But when I start using PHP, I
find no such document of it and I have been using it for 3 years without a
problem.  I asked people is there such a thing as converting it by using
   

the
 

function and they told me there is no such a thing and that it is done
automatically...  Now my time is a little bit wasted.   So, I will correct
the problem with the php script...

I recently looked up on the manual as Jason Wong instructed me to.  I
havne't found the answer since the document is a little bit mixed up.

Okay, I'm going back to my old way as I did in javascript and c
   

programming.
 

So for php, it would be

floatval() for float...
strval() for string
settype() for whatever..
intval() for integer

Um, what about double???

Thanks,
Scott F.

Chris Hayes [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   

Re: [PHP] Found a PHP bug!
uh oh...


 

I don't see why a string wouldn't work when I use 08 (string) and
   

match
 

it
   

against the integer 8, or 08.
   

They're just different types. Normally PHP is veeery flexible with
types,  like javascript, but it just can't be flexible for you here
 

because
   

it needs to choose the most logic to the entire pool of programmers, and
 

then
   

08 = a string
  8 = a decimal integer
 08 = by definition an impossible octal integer, so 0.

Since you cannot tell PHP that $var is of a certain type like in [other]
programming languages, for example you want it to be treated as an
 

integer,
   

PHP will handle it as what seems to be the most logic.


You can try to use intval (does not alter a variable, only the value as
 

it
 

is used in a calculation or an if() statement) or settype (alters the
variable).



 

Kirk Johnson [EMAIL PROTECTED] wrote in message
B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...
   

-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]]

Found a PHP bug, I'm using PHP version 4.2.3.  I have been
struggling with
why PHP code failed to work with the month is August or
September
   

I stumbled into this one a short while ago myself. It is not a bug,
 

but a
   

feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP
 

interprets
   

them as octal numbers (because of the leading 0). However, 08 and 09
 

are
   

invalid octal numbers, so PHP converts them to zero.

The fixes are numerous:
- remove the leading zero;
- add zero to them before passing (addition forces a type
 

conversion
 

to
   

int);
- force a type conversion to integer using (int);
- quote them (when PHP converts a string to an integer, it removes
 

the
   

leading zero);

Kirk
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   

 

   




 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.





Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread 1LT John W. Holmes
Even doing a type cast won't make a difference for the original problem.
Even if you cast 08 to an integer and compare it to 08 (invalid octal
number), it'll still fail.

The original solution was the best, remove the leading zero from the
comparisons and let PHP handle the type casting.

---John Holmes...

- Original Message -
From: Ray Hunter [EMAIL PROTECTED]
To: Scott Fletcher [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, January 27, 2003 3:45 PM
Subject: Re: [PHP] Found a PHP bug!


 U might want to do a type cast to integer from string...

 http://www.php.net/manual/en/language.types.type-juggling.php


 On Mon, 2003-01-27 at 13:47, Scott Fletcher wrote:
  I would need to use intval() to solve this problem
 
  Scott Fletcher [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   I'm referring to '08' and '09' that don't work
  
   Chris Shiflett [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
--- Scott Fletcher [EMAIL PROTECTED] wrote:
     Found a PHP bug
...
 if ($month == 01)
   
I guess you mean:
   
if ($month == '01')
   
If so, this is not a bug. Otherwise, please explain what
you think is wrong.
   
Chris
  
  


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Cal Evans
John.

 Actually, 08 is equal to 8 in PHP. PHP will convert the string to an
integer and the two will compare as equal.

No they are not equal. Yes, PHP will do the conversion so that they are
equal. That does not refute the fact that logically '08' != 8.


 Someone already posted why the problem was happening, because the numbers
 were being converted to invalid octal numbers and being set to zero.

I understand the problem at hand. (and did when I posted) However, if Scott
had been doing the conversions manually, he would never have run across this
problem.  It is a bad idea to rely on the language (whatever the language)
to do automatic variable conversions.

=C=


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Yea, it's too bad that not many people know about it.  I first asked and
they told me it is done automatically.  That was 3 years ago.  I never had a
problem for 3 years until now.  So, I'm going back to the old way as I did
in Javascript and C programming.  I first started PHP 3 years ago, so it's
no wonder why there's all the confusion when I was just an innocent victim.
:-)

Cal Evans [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 John.

  Actually, 08 is equal to 8 in PHP. PHP will convert the string to an
 integer and the two will compare as equal.

 No they are not equal. Yes, PHP will do the conversion so that they are
 equal. That does not refute the fact that logically '08' != 8.


  Someone already posted why the problem was happening, because the
numbers
  were being converted to invalid octal numbers and being set to zero.

 I understand the problem at hand. (and did when I posted) However, if
Scott
 had been doing the conversions manually, he would never have run across
this
 problem.  It is a bad idea to rely on the language (whatever the language)
 to do automatic variable conversions.

 =C=




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Double and Float are not exactly the same thing.

Double is --- 11.123
Float is -- .00238823993

Leif K-Brooks [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 No, it's floatval.  Doubleval is an alias left over from hwen floats
 were called doubles...

 Scott Fletcher wrote:

 Whoop!  FOund it,  it is doubleval()...
 
 
 What does settype() do exactly
 
 
 Scott Fletcher [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
 
 I do know that integer, string, double, float, etc  are different..
I
 have been using hte appropriate method like in javascript and c
 
 
 programming,
 
 
 like converting it to integer and so on  But when I start using PHP,
I
 find no such document of it and I have been using it for 3 years without
a
 problem.  I asked people is there such a thing as converting it by using
 
 
 the
 
 
 function and they told me there is no such a thing and that it is done
 automatically...  Now my time is a little bit wasted.   So, I will
correct
 the problem with the php script...
 
 I recently looked up on the manual as Jason Wong instructed me to.  I
 havne't found the answer since the document is a little bit mixed up.
 
 Okay, I'm going back to my old way as I did in javascript and c
 
 
 programming.
 
 
 So for php, it would be
 
 floatval() for float...
 strval() for string
 settype() for whatever..
 intval() for integer
 
 Um, what about double???
 
 Thanks,
  Scott F.
 
 Chris Hayes [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
 
  Re: [PHP] Found a PHP bug!
 uh oh...
 
 
 
 
 I don't see why a string wouldn't work when I use 08 (string) and
 
 
 match
 
 
 it
 
 
 against the integer 8, or 08.
 
 
 They're just different types. Normally PHP is veeery flexible with
 types,  like javascript, but it just can't be flexible for you here
 
 
 because
 
 
 it needs to choose the most logic to the entire pool of programmers,
and
 
 
 then
 
 
 08 = a string
8 = a decimal integer
   08 = by definition an impossible octal integer, so 0.
 
 Since you cannot tell PHP that $var is of a certain type like in
[other]
 programming languages, for example you want it to be treated as an
 
 
 integer,
 
 
 PHP will handle it as what seems to be the most logic.
 
 
 You can try to use intval (does not alter a variable, only the value as
 
 
 it
 
 
 is used in a calculation or an if() statement) or settype (alters the
 variable).
 
 
 
 
 
 Kirk Johnson [EMAIL PROTECTED] wrote in message
 B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...
 
 
 -Original Message-
 From: Scott Fletcher [mailto:[EMAIL PROTECTED]]
 
 Found a PHP bug, I'm using PHP version 4.2.3.  I have been
 struggling with
 why PHP code failed to work with the month is August or
 September
 
 
 I stumbled into this one a short while ago myself. It is not a bug,
 
 
 but a
 
 
 feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP
 
 
 interprets
 
 
 them as octal numbers (because of the leading 0). However, 08 and 09
 
 
 are
 
 
 invalid octal numbers, so PHP converts them to zero.
 
 The fixes are numerous:
  - remove the leading zero;
  - add zero to them before passing (addition forces a type
 
 
 conversion
 
 
 to
 
 
 int);
  - force a type conversion to integer using (int);
  - quote them (when PHP converts a string to an integer, it removes
 
 
 the
 
 
 leading zero);
 
 Kirk
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
 
 
 
 
 

 --
 The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Aw nut!!!  The intval() doesn't work..  I had enough, I'm going to do
what Kirk Johnson recommend.  That one work better.

Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Yea, it's too bad that not many people know about it.  I first asked and
 they told me it is done automatically.  That was 3 years ago.  I never had
a
 problem for 3 years until now.  So, I'm going back to the old way as I did
 in Javascript and C programming.  I first started PHP 3 years ago, so it's
 no wonder why there's all the confusion when I was just an innocent
victim.
 :-)

 Cal Evans [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  John.
 
   Actually, 08 is equal to 8 in PHP. PHP will convert the string to an
  integer and the two will compare as equal.
 
  No they are not equal. Yes, PHP will do the conversion so that they are
  equal. That does not refute the fact that logically '08' != 8.
 
 
   Someone already posted why the problem was happening, because the
 numbers
   were being converted to invalid octal numbers and being set to zero.
 
  I understand the problem at hand. (and did when I posted) However, if
 Scott
  had been doing the conversions manually, he would never have run across
 this
  problem.  It is a bad idea to rely on the language (whatever the
language)
  to do automatic variable conversions.
 
  =C=
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Another workaround to this problem is as an addition to Kirk Johnson's
suggestion

--clip--
$month = 08;
 if (trim($month) == 8) {
echo You got it!!!;
 }
--clip--
Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Aw nut!!!  The intval() doesn't work..  I had enough, I'm going to do
 what Kirk Johnson recommend.  That one work better.

 Scott Fletcher [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Yea, it's too bad that not many people know about it.  I first asked and
  they told me it is done automatically.  That was 3 years ago.  I never
had
 a
  problem for 3 years until now.  So, I'm going back to the old way as I
did
  in Javascript and C programming.  I first started PHP 3 years ago, so
it's
  no wonder why there's all the confusion when I was just an innocent
 victim.
  :-)
 
  Cal Evans [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   John.
  
Actually, 08 is equal to 8 in PHP. PHP will convert the string to
an
   integer and the two will compare as equal.
  
   No they are not equal. Yes, PHP will do the conversion so that they
are
   equal. That does not refute the fact that logically '08' != 8.
  
  
Someone already posted why the problem was happening, because the
  numbers
were being converted to invalid octal numbers and being set to zero.
  
   I understand the problem at hand. (and did when I posted) However, if
  Scott
   had been doing the conversions manually, he would never have run
across
  this
   problem.  It is a bad idea to rely on the language (whatever the
 language)
   to do automatic variable conversions.
  
   =C=
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Leif K-Brooks

 doubleval

doubleval -- Alias of floatval() 
http://www.php.net/manual/en/function.floatval.php


   Description

This function is an alias of floatval() 
http://www.php.net/manual/en/function.floatval.php.

   Note: This alias is a left-over from a function-renaming. In older
   versions of PHP you'll need to use this alias of the floatval()
   http://www.php.net/manual/en/function.floatval.php function,
   because floatval()
   http://www.php.net/manual/en/function.floatval.php wasn't yet
   available in that version.



Scott Fletcher wrote:

Double and Float are not exactly the same thing.

Double is --- 11.123
Float is -- .00238823993

Leif K-Brooks [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 

No, it's floatval.  Doubleval is an alias left over from hwen floats
were called doubles...

Scott Fletcher wrote:

   

Whoop!  FOund it,  it is doubleval()...


What does settype() do exactly


Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


 

I do know that integer, string, double, float, etc  are different..
   

I
 

have been using hte appropriate method like in javascript and c


   

programming,


 

like converting it to integer and so on  But when I start using PHP,
   

I
 

find no such document of it and I have been using it for 3 years without
   

a
 

problem.  I asked people is there such a thing as converting it by using


   

the


 

function and they told me there is no such a thing and that it is done
automatically...  Now my time is a little bit wasted.   So, I will
   

correct
 

the problem with the php script...

I recently looked up on the manual as Jason Wong instructed me to.  I
havne't found the answer since the document is a little bit mixed up.

Okay, I'm going back to my old way as I did in javascript and c


   

programming.


 

So for php, it would be

floatval() for float...
strval() for string
settype() for whatever..
intval() for integer

Um, what about double???

Thanks,
Scott F.

Chris Hayes [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


       

Re: [PHP] Found a PHP bug!
   

uh oh...




 

I don't see why a string wouldn't work when I use 08 (string) and


   

match


 

it


   

against the integer 8, or 08.


   

They're just different types. Normally PHP is veeery flexible with
types,  like javascript, but it just can't be flexible for you here


 

because


   

it needs to choose the most logic to the entire pool of programmers,
 

and
 

 

then


   

08 = a string
 8 = a decimal integer
08 = by definition an impossible octal integer, so 0.

Since you cannot tell PHP that $var is of a certain type like in
 

[other]
 

programming languages, for example you want it to be treated as an


 

integer,


   

PHP will handle it as what seems to be the most logic.


You can try to use intval (does not alter a variable, only the value as


 

it


 

is used in a calculation or an if() statement) or settype (alters the
variable).





 

Kirk Johnson [EMAIL PROTECTED] wrote in message
B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef">news:B11731D518B5D61183C700A0C98BE0D9FFBE5D@chef...


   

-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]]

Found a PHP bug, I'm using PHP version 4.2.3.  I have been
struggling with
why PHP code failed to work with the month is August or
September


   

I stumbled into this one a short while ago myself. It is not a bug,


 

but a


   

feature! ;) When passing values of 08 or 09 (Aug and Sep), PHP


 

interprets


   

them as octal numbers (because of the leading 0). However, 08 and 09


 

are


   

invalid octal numbers, so PHP converts them to zero.

The fixes are numerous:
- remove the leading zero;
- add zero to them before passing (addition forces a type


 

conversion


 

to


   

int);
- force a type conversion to integer using (int);
- quote them (when PHP converts a string to an integer, it removes


 

the


   

leading zero);

Kirk


 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


   

 

   




 

--
The above message is encrypted with double rot13 encoding.  Any
   

unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.
 


   




 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 Double and Float are not exactly the same thing.
 
 Double is --- 11.123
 Float is -- .00238823993

They are the same thing. Please, read this:

http://www.php.net/manual/en/language.types.php

and this:

http://www.php.net/manual/en/language.types.float.php

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread White Wolf
Scott Fletcher wrote:
 Double and Float are not exactly the same thing.

 Double is --- 11.123
 Float is -- .00238823993

I am absolutely new to PHP but what is above (since PHP seems to take most
of its low-level terminology from C) is a fixed point number and the next
is a floating point number, which may not fit into the 8 significant digits
what is guaranteed for a float on all platforms.  What do I miss?

WW



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread Scott Fletcher
Okay, correction...

Double -- 11.1237
Float -- 0.

Cheers!  It's the way it work in C Programming...  Double won't be as long
or as infinite as the floating point.


White Wolf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Scott Fletcher wrote:
  Double and Float are not exactly the same thing.
 
  Double is --- 11.123
  Float is -- .00238823993

 I am absolutely new to PHP but what is above (since PHP seems to take most
 of its low-level terminology from C) is a fixed point number and the next
 is a floating point number, which may not fit into the 8 significant
digits
 what is guaranteed for a float on all platforms.  What do I miss?

 WW





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Found a PHP bug!!!!!!!!!

2003-01-27 Thread White Wolf
Scott Fletcher:
 Okay, correction...

 Double -- 11.1237
 Float -- 0.

 Cheers!  It's the way it work in C Programming...  Double won't be as
long
 or as infinite as the floating point.

Absolutely wrong (if you would be in a C newsgroup you would even be
accused of trolling :-)))

double (in C) means: double precision floating point number

float in C means: floating point number

Float is guaranteed to store 6 significant digits (and usually noone uses
it except on some very weird architectures) while double's minimum is 10
significant digits.

WW



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php