2014-06-21 12:28 GMT+02:00 Tobias Boege <tabo...@gmail.com>:

> On Sat, 21 Jun 2014, Patrik Karlsson wrote:
> > 1. Why is Abs(True) True?
>
> Because the mapping Integer -> Boolean is not injective. The rule is: 0
> maps
> to False, everything else maps to True. To be able to map Boolean ->
> Integer
> the convention used in Gambas is False maps to zero (of course) and True
> maps
> to -1, which makes actually sense if you don't look into the array index
> but
> into the bit flags direction (True means "all bits set" in Gambas, which is
> what -1 is in two's complement). So what happens is:
>
> Abs(True) becomes Abs(CInt(True)) on the fly which is Abs(-1) = 1 which is
> non-zero and thus True again.


 That was interesting, thanks.

/Patrik
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to