|
| unexpected results for == |
 |
Tue, 25 Mar 2008 14:37:30 -040 |
dBASE PLUS 2.6.1.3 Win XP Pro SP2
in command window type
x = 0
? x // returns 0 as expected
? type('0') // returns 'N' as expected
? x == false // returns true - is that WAD? I would expect an error
|
| Post Reply
|
| Re: unexpected results for == |
 |
Tue, 25 Mar 2008 17:42:58 -040 |
Bruce,
Guess I will to from now on.
Thanks
Frank Polan
On Tue, 25 Mar 2008 21:04:47 +0000, Bruce Beacham
<bbeacham@beacham.no-spam.co.uk> wrote:
>Frank J. Polan wrote:
>> x = 0
>
>> ? x == false // returns true - is that WAD? I would expect an error
>
>There's a general feature of a number of languages which go back
>decades, that false can be indicated by a 0 and true can be indicated by
>a 1. You can see why, of course - it's economical.
>
>I've noticed this in dBASE and so when I generate return values to x
>that may be false or may be a count of some sort, I make x private and
>test for type().
>
>
>Bruce Beacham
|
| Post Reply
|
| Re: unexpected results for == |
 |
Tue, 25 Mar 2008 21:04:47 +000 |
Frank J. Polan wrote:
> x = 0
> ? x == false // returns true - is that WAD? I would expect an error
There's a general feature of a number of languages which go back
decades, that false can be indicated by a 0 and true can be indicated by
a 1. You can see why, of course - it's economical.
I've noticed this in dBASE and so when I generate return values to x
that may be false or may be a count of some sort, I make x private and
test for type().
|
| Post Reply
|
| Re: unexpected results for == |
 |
Wed, 26 Mar 2008 08:44:06 -040 |
In article <op6km6rjIHA.700@news-server>, bbeacham@beacham.no-spam.co.uk
says...
> Frank J. Polan wrote:
> > x = 0
>
> > ? x == false // returns true - is that WAD? I would expect an error
>
> There's a general feature of a number of languages which go back
> decades, that false can be indicated by a 0 and true can be indicated by
> a 1. You can see why, of course - it's economical.
In many cases, ANY non-zero value is "true", but ideally (or by
language
definition), true = -1.
--
Remove the ns_ from if replying by e-mail (but keep posts in the
|
| Post Reply
|
| Re: unexpected results for == |
 |
Wed, 26 Mar 2008 15:03:13 +000 |
ns_dkerber@ns_warrenrogersassociates.com wrote:
>> a 1. You can see why, of course - it's economical.
>
> In many cases, ANY non-zero value is "true", but ideally (or by
language
> definition), true = -1.
That's interesting. Needs an extra bit though, I imagine!
|
| Post Reply
|
|
|
|
|
|
|
|
|
|