Topic: Boolean type wanted
Author: Chuck Allison <72640.1507@CompuServe.COM>
Date: 16 Dec 1994 00:27:21 GMT Raw View
The C++ standard committee draft defines a type bool, which is
C++'s answer to a boolean type. It should appear in your favorite
compiler "soon".
-- Chuck Allison
--
Chuck Allison
Compuserve: 72640,1507
INTERNET: 72640.1507@compuserve.com
Author: jbuck@synopsys.com (Joe Buck)
Date: 13 Dec 1994 18:49:03 GMT Raw View
tarmstro@ing.udec.CL (Thomas Armstrong Kobrich) writes:
>Joe Buck (jbuck@synopsys.com) wrote:
>
>
>> The Last American Virgin <eos@freud.inst.com> writes:
>> >: NN> Is there a simple way to make a boolean type for variables?
>
>
> Look in the book 'C++ Primer' (don't remember the author right now)
>There is an approach of using single bits for boolean variables.
Note that nothing by me appears in the above posting. Please be
careful with attributions: you could make it appear that an experienced
person is asking a beginner's question, as in the above, for example.
--
-- Joe Buck <jbuck@synopsys.com> (not speaking for Synopsys, Inc)
Phone: +1 415 694 1729
Author: tarmstro@ing.udec.CL (Thomas Armstrong Kobrich)
Date: Mon, 12 Dec 1994 17:45:29 GMT Raw View
Joe Buck (jbuck@synopsys.com) wrote:
> The Last American Virgin <eos@freud.inst.com> writes:
> >: NN> Is there a simple way to make a boolean type for variables?
Look in the book 'C++ Primer' (don't remember the author right now)
There is an approach of using single bits for boolean variables.
--
------------------------------------------------------------------
| Thomas Armstrong Kobrich | tarmstro@caleuche.dis.udec.cl |
| Concepcion - Chile | tarmstro@canelo.ing.udec.cl |
------------------------------------------------------------------
Author: mlc@wup.de (Michael Lechner)
Date: 7 Dec 1994 11:02:26 GMT Raw View
Dag Bruck (dag@control.lth.se) wrote:
: >>>>> "NN" == The Last American Virgin <eos@freud.inst.com> writes:
: NN> Is there a simple way to make a boolean type for variables?
: I suggest the following:
: typedef int bool;
: const bool false = 0;
: const bool true = 1;
I would suggest true = -1... (or ~0, or !false). ;-)
Michael
--
+-------------------------------+--------------------------------------+
| Michael Lechner | Wiechers & Partner Datentechnik GmbH |
| | Forschung & Entwicklung |
| | An der alten Ziegelei 2 |
| eMail: mlc@wupmon.wup.de | D-40771 Monheim (Germany) |
+-------------------------------+--------------------------------------+
Author: eos@freud.inst.com (The Last American Virgin)
Date: 2 Dec 1994 12:37:04 -0600 Raw View
Is there a simple way to make a boolean type for variables?
Im using Borland TC++ V1.0
Thanks,
Noby Nobriga
Author: dag@control.lth.se (Dag Bruck)
Date: 02 Dec 1994 19:39:00 GMT Raw View
>>>>> "NN" == The Last American Virgin <eos@freud.inst.com> writes:
NN> Is there a simple way to make a boolean type for variables?
I suggest the following:
typedef int bool;
const bool false = 0;
const bool true = 1;
This won't give you much (e.g., no overloading), but you will be in
good shape when you upgrade to a compiler with the new built-in bool
type.
-- Dag Bruck
Author: ark@research.att.com (Andrew Koenig)
Date: Wed, 7 Dec 1994 17:33:56 GMT Raw View
In article <3c44o2$gkv@wup-gate.wup.de> mlc@wup.de (Michael Lechner) writes:
> I would suggest true = -1... (or ~0, or !false). ;-)
Why?
--
--Andrew Koenig
ark@research.att.com
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 7 Dec 1994 18:02:40 GMT Raw View
In article gkv@wup-gate.wup.de, mlc@wup.de (Michael Lechner) writes:
>Dag Bruck (dag@control.lth.se) wrote:
>: >>>>> "NN" == The Last American Virgin <eos@freud.inst.com> writes:
>
>: NN> Is there a simple way to make a boolean type for variables?
>
>: I suggest the following:
>
>: typedef int bool;
>: const bool false = 0;
>: const bool true = 1;
>
>I would suggest true = -1... (or ~0, or !false). ;-)
This is comp.STD.c, and the forthcoming standard will define 'true' to
have the value 1. Also note your '!false' would have the value 1, not -1.
---
Steve Clamage, stephen.clamage@eng.sun.com
Author: dag@control.lth.se (Dag Bruck)
Date: 07 Dec 1994 21:35:03 GMT Raw View
> Dag Bruck (dag@control.lth.se) wrote:
> :
> : typedef int bool;
> : const bool false = 0;
> : const bool true = 1;
>
> I would suggest true = -1... (or ~0, or !false). ;-)
I see the ;-) so I shouldn't be nit-picking, but please note that
x > 3
returns either 0 or 1 (not an arbitrary non-zero number).
-- Dag Bruck
Author: jbuck@synopsys.com (Joe Buck)
Date: 7 Dec 1994 23:12:07 GMT Raw View
The Last American Virgin <eos@freud.inst.com> writes:
>: NN> Is there a simple way to make a boolean type for variables?
Dag Bruck (dag@control.lth.se) wrote:
>: I suggest the following:
>
>: typedef int bool;
>: const bool false = 0;
>: const bool true = 1;
>
mlc@wup.de (Michael Lechner) writes:
>I would suggest true = -1... (or ~0, or !false). ;-)
Bad idea, Michael. With your definition, the expression (0 == 0)
does not have the value "true" (since its value in C and older C++
compilers is the integer 1, not -1).
--
-- Joe Buck <jbuck@synopsys.com> (not speaking for Synopsys, Inc)
Phone: +1 415 694 1729