10-28-2009 09:37 AM
Not sure if this was ever a factor when that decision was made, but in C Booleans are commonly represented by (signed) integers, and a value of 0 was considered to be False, while any non-zero value was considered to be True. In fact, it was quite common to see something like this:
#define FALSE (0)
#define TRUE (-1)
typedef int bool;
Furthermore, the size of "int" has not always been the same, as we've gone from 8-bit processors to 32 and 64-bit processors. So, at one point, "int" was really just 16-bits. Nowadays we affectionately know it as a "short int". How long will it be, I wonder, when the 32-bit integer is known as "short int", and the 16-bit integer is known as "stunted int"?
10-28-2009 09:53 AM
10-28-2009 09:56 AM
You don't like I16, make your own Boolean to 0,1:
10-28-2009 10:03 AM
10-28-2009 10:12 AM
GerdW wrote:Hi Nickerbocker,
why not extend your example to a new LV idea:
make the output datatype of "boolean to 0/1" configurale as you can do for other functions (like "add"...). Atleast any integer type should be allowed!
As Ben noted, there's an existing idea for that. Let's all go Kudo it!
10-28-2009 10:12 AM
Darin.K wrote:
Along those lines, a couple of things I had to ween myself from in going from C to LV were side-effects and short-circuits. Useful constructs in C where you have a simple intermingling of booleans and numbers. In LV with booleans sequestered to their own type, I have never fully understood the logic behind their representation. (Except for the time when they were 1-bit in an array, that makes sense).
The KL-10
instruction set was the most powerful set I ever worked with. it was developed by a bunch of EE that understood computers but did not program them. Included in that instruction set were machine level operations that let you compute complex surfaces like a sadle (hyperpola up combined with another down). A whole section of the command set included support for varible bit field lengths so we could work with 3-bit nibbles if we wanted.
After an adventure through the VAX-11
instruction set ( included commands like Insert at head of queue interlocked to support multi-CPUs sharing memory) the wolrd responded with RISC (reduced instruction set computers) that settled on a minimal set of instruction that could be combined to realized those crazy instruction found in the robust architectures.
So...
Single bit representations were just too fancy AND the CPU had to work in "register-sized" chuncks anyway so why bother with including logic for single bit operations.
Just my 2 cents,
Ben
10-28-2009 10:15 AM
Ben wrote:
Single bit representations were just too fancy AND the CPU had to work in "register-sized" chuncks anyway so why bother with including logic for single bit operations.
Just my 2 cents,
Ben
So, you're saying that a bit is like a penny? We're going to need have a "Need a bit, give a bit" little container next to computers...
10-28-2009 11:17 AM
10-29-2009 10:08 AM - edited 10-29-2009 10:09 AM
GerdW wrote:Hi Randy,
two facts:
1) a boolean is (nowadays) stored as 8bit entity internally
2) any value different than zero is TRUE
Do you need more hints?
Still stumped. I get that this is somehow a memory thing, because I deleted a bunch of the bools in JP's array and then added them back in and just got x01 for each one I put back in. But I don't understand... Oh wait. I get it now! Funny how typing things out can make it make sense. I hadn't thought about looking at it from that angle (obviously)... Thanks!