Topic: bool question


Author: jason@cygnus.com (Jason Merrill)
Date: Thu, 28 Jul 1994 01:10:44 GMT
Raw View
>>>>> Ronald F Guilmette <rfg@netcom.com> writes:

> There are also implicit conversions from floating-point types and pointer
> types to type bool.

Don't forget pointer to member...

Jason




Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Wed, 27 Jul 1994 06:53:52 GMT
Raw View
In article <DAG.94Jul18152751@bode.control.lth.se> dag@control.lth.se (Dag Bruck) writes:
>
>> I have some questions about how the new "bool" type will work:
>>     int i4 = 4;
>>     int i5 = 5;
>>     bool b4 = i4;      // Legal without cast? Is value true?
>
>Zero becomes false, any other value becomes true.
>No cast is needed (unfortunately).

In fact (as I have just learned) it's even worse than that.

There are also implicit conversions from floating-point types and pointer
types to type bool.

--

-- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting -------------------
---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ----
---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -




Author: davem@eden.rutgers.edu (David Miller)
Date: 20 Jul 94 04:37:26 GMT
Raw View
Kevin J Hopps (hopps@mmm.com) wrote:
: I have some questions about how the new "bool" type will work:
:     int i4 = 4;
:     int i5 = 5;
:     bool b4 = i4;      // Legal without cast? Is value true?

 Yes, b4 will be implicitly cast and will equal true.

:     i4 = b4;           // Legal without cast? What is i4 now?

 Yes, i4 will be cast to int from bool and equal 1.

:     bool b5 = i5;
:     bool b = (b4==b5); // true or false?

 Ok, b will equal true here because both i4 and i5 were
non-zero and thus cast to true for both b4 and b5, thus b = true.

Later,
David S. Miller
davem@eden.rutgers.edu




Author: hopps@mmm.com (Kevin J Hopps)
Date: 15 Jul 1994 18:38:55 GMT
Raw View
I have some questions about how the new "bool" type will work:
    int i4 = 4;
    int i5 = 5;
    bool b4 = i4;      // Legal without cast? Is value true?
    i4 = b4;           // Legal without cast? What is i4 now?
    bool b5 = i5;
    bool b = (b4==b5); // true or false?
--
Kevin J. Hopps                  e-mail: kjhopps@mmm.com
3M Company                      phone:  (612) 737-3300
3M Center, Bldg. 235-3B-16      fax:    (612) 737-2700
St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.




Author: dag@control.lth.se (Dag Bruck)
Date: 18 Jul 1994 13:27:51 GMT
Raw View
> I have some questions about how the new "bool" type will work:
>     int i4 = 4;
>     int i5 = 5;
>     bool b4 = i4;      // Legal without cast? Is value true?

Zero becomes false, any other value becomes true.
No cast is needed (unfortunately).

>     i4 = b4;           // Legal without cast? What is i4 now?

False becomes 0, true comes 1, i.e., i4 becomes 1.

>     bool b5 = i5;
>     bool b = (b4==b5); // true or false?

b becomes true because both b4 and b5 are true.

    -- Dag