Re: A really wacky design decision

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 4 Oct 2009 14:52:36 +0200, an_red@xxxxxxxxxxx (Andrea Giammarchi) wrote:

>
>
>
>> 	$a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0;
>> 
>> 	$a==$b==$c==$d,
>> 
>> and
>> 	$b===$c===$d
>
>$b , $c, and $d are the same indeed ... they represent the floating point 2260.0 in I think every language ... it's like saying that 1.0 is not 1.0000 ... both floating point numbers, so I don't get your problem ...

IF they are actually floating point numbers. My problem is that I'm working with values
which are strings, but which sometimes look like either integers or floating point
numbers. And I apologise for falsely contradicting your previous message; I realised
subsequently that I had forgotten to specify the variables as strings in my test. Thus, if
I write:

	$a = 2260; $b = '2260'; the exact comparison returns 'false'.

The same applies to all the cases I had been complaining about, and the exact comparison
does indeed work as you stated. This piece of carelessness arose because my data is
represented in the simple form, eg:

A;e;21TH;AP;;;;Musical education;090701

but is implicitly converted into strings when it is entered.

(And I tend to be wary of determining the rules experimentally. I learned my programming
on CDC3200 Fortran fortysomething years ago. Manuals were brief and textbooks
non-existent, so whenever we were not sure of something we would try it. Unfortunately the
Fortran had some very strange design features, which we learnt about when our employer
upgraded to a CDC 6600. This used a much more standard Fortran, and many of the tricks we
had discovered no longer worked.)


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux