Bit Casting

• Thanks for the easy one!

Have a good week-end!

Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com

• TomThomson (12/18/2014)

Sean Lange (12/18/2014)

Good question. Let's not forget that this is NOT a real representation of a boolean. A bit in sql server can have 3 values with NULL being the third.

It actually is a real representation of a boolean. Being able to be NULL instead of having a value is an inherent property of booleans in the real world (and also in the world of mathematics).

As far as booleans are concerned there are two values that they can have. It's also possible that for a particular boolean you don't know the value. That is represented n SQL by an SQL value not constrained not to be null. Of course there are times when one wants to refer to a boolean value where the value, whatever it may be, will always be known. This can of course be expressed perfectly well an attribute or a row in a table, using the bit type qualified by NOT NULL , but can't be expressed for an SQL local variable (local variablies are a bit of a pigs breakfast in SQL semantics for that reason amongst others).

So SQL has two different sorts of bits: both sorts have two values, and only two values, so as far as their values are concerned they are real representations of a boolean value. One of those two sorts is such that it is always known what its value is, so is what one might call an ideal boolean. The other is a the real world boolean, which admits the possiblility that at any given time the value may not be known.

So I don't think that it's realistic to say that bit is not a real representation of a boolean.

There are some rather nice examples of boolean values that are unknown in mathematics: for example suppose F is a partial recursive function, P is the proposition "if F is applied to 0 at 1.00 am using a computer capable of 10**10 Mflop/s the computation will terminate by 5pm this afternoon". The tructh value for proposition is a boolean, it is either true or false, but it may be impossible to determine which it is before someone has tried the experiment. So until the question has been resolved by experiment, the value is unknown and SQL will correctly represent that situation by responding NULL instead of delivering a 1 or 0 value to a request for the value of P until such time as the experiment has been carried out and the result inserted into the database. And there are nastier examples: suppose the proporsition is "if F is applied to 0 the computation will eventually terminate with a valid result provided enough computational power is supplied for enough time"; it is a proven fact of computational theory (since over three quarters of a century ago) that for some values of F the value of the corresponding proposition P can never be known unless P is true, and it can only be known that it's true if someone has actualy carried out the computation and it terminated with a valid result, and it is impossible in general to determine whether any particular F is or is not such an F (independent proofs were made by Gödel - the incompleteness theorem - and Turing - the halting problem - and by others), so a proper representation of a boolean must allow it to be NULL instead of having a value unless there are very solid grounds for claiming that its value is always known.

Tom I agree with you on this, but please correct me if I am wrong in the way I think of it. Logically I have thought that the boolean is a result or state either before or after a test. The result of a test being true or false. Logically then if the test has not been performed there is no result therefore null. The state of the boolean operator then tells three things, a true test result, a false test result, and that the test has not yet been performed.

M.

Not all gray hairs are Dinosaurs!

• Miles Neale (12/19/2014)

Tom I agree with you on this, but please correct me if I am wrong in the way I think of it. Logically I have thought that the boolean is a result or state either before or after a test. The result of a test being true or false. Logically then if the test has not been performed there is no result therefore null. The state of the boolean operator then tells three things, a true test result, a false test result, and that the test has not yet been performed.

M.

Yes, I agree that that's one way of looking it, and perfectly valid (if sometimes not the most convenient way of looking at it): it has 3 states, and in two of those states it has a value(true in one of those two states, false in the other); in the other state it doesn't have a value. Another way of looking at it is that it has two states, in one of which it has one of two possible values and another in which it doesn't have a value (that's my usual way of thinking of it, because it means that all variables in a logical calculus always have two sates, regardless of how many values the can have when they have values, and it's useful to have commonalities across the logics because techniques of manipulation can then be shared and some things become much simpler).

That extra commonality between different logics is especially useful because using two valued logic (whether with three states or with two) is sometimes not useful, and mathematicians tend to be fairly well accustomed to logics with an infinte collection of values, especially mathematicians of the constructivist school or the intuitionist school (which have a lot of overlap) but even what you might call "classical" mathematicians (those who avoid anything that smells of philosophical difficulties) tend to be familiar with logics with more than 2 values.

Tom

• Thank you Tom!

Miles...

Not all gray hairs are Dinosaurs!

Viewing 4 posts - 16 through 18 (of 18 total)