- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
They're just duals of each other. No need to say anything more than that.
http://en.wikipedia.org/wiki/Duality_(mathematics)#Duality_in_logic_and_set_theory
Admin
Among the etc. that you need to include is some way to make derived classes compile. (A class with a private destructor cannot be a base class because the derived class's destructor cannot call the base class's destructor.) Also, the mere fact that you can gabble this out doesn't tell me you know anything about the implications of
delete this;
, and also doesn't do what I asked. I asked you to talk to me about the construction, not gabble out broken code. FAIL.Still, your answer told me what I needed to know. You showed yourself to be careless and incapable of following instructions. Thanks for playing. NO HIRE.
Admin
Not exactly in shell. For example, a lot of scripts use the pattern
test && success || fail
, like this:Which will output
y
first and thenn
for the second command, much like is suggested. But then, if you try and do more complicated things thatecho
-ing text, you see that it works slightly differently. Suppose our success command fails, like this:This will print
meow
, perhaps slightly unexpectedly. Now look at some other possible combinations, and try and work out what the output will be:We get
one
,two
andthree
output, only the last command fails to output anything...I've been caught out by trying to be too clever with shell short-circuit operators too often, particularly when trying to programmatically generate scripts (TRWTF) so I usually end up rewriting the
test && success || failure
one liners like the following, which works as expected:Filed under Tag Precedence Exception
Admin
It's smarter to not be a smartass. Sometimes I remember this when coding… ;)
Admin
Well, maybe 0 is the only integral constant that can be directly assigned, but I see no reason why such a field couldn't hold a value of ~0
Admin
You don't know (without looking in the compiler's manual) whether flaky.x is signed or unsigned, and you don't know (without looking in the machine's architecture manual AND the compiler's manual) what exactly is meant by a signed field consisting only of a sign bit, except that an all-bits-zero int-family variable is, by definition, zero.
So the portable range of values is 0..0. Done.
Admin
The portable range of values is 0..1. How you interpret the values in the portable range is up to your compiler.
Admin
Admin
Hhm. A computer wouldn't perform any calculations for logical operations, it would just check the presence of any bits, or if a branch is performed on the presence of a single bit (like the sign bit), check this bit.
E.g.: DEC PDP-1, 1's complement, 18-bit words, -0 = 0777777:
So, what would the console lights for AC reading? 0, 1, or -0 (0777777)? Answer: 0777777 has all bits set, there are some bits set to high in AC, AC is not zero. Therefor we don't skip and execute
law 1
and the contents of AC is thus 1.There is no such thing like Boolean arithmetics on the machine level, they are all in the compilers of higher level languages.
Admin
Or arguably that's virtually all that you've got. (Addition is just a wrapper round XOR and AND…)
Admin
XOR and AND are just wrappers around NAND ...
Admin
Not really. The gate libraries are a bit higher-level than that, as they can build things more efficiently if they don't force everything to be a single simple transistor.
Admin
Yes, I expect a half-adder (and quite possibly a full-adder) is available there as well.
Admin
It's possible to create every logic gate using only NAND gates.
It's not done in practice, because it's very expensive in transistors. (Compared to just creating the gates the normal way.)
Admin
Admin
Generally speaking, there are no "single simple transistors" in logic gates. Even an inverter is two transistors. A 2-input NAND (or NOR) is 4 transistors. A 3-input NAND is 6.
There are a few places where you'll find single transistors. A DRAM cell is a single transistor (and a capacitor). Single transistors are also used where a simple make-or-break connection is needed. For example, FPGAs are chips that have a zillion logic gates that can be connected together in a zilliion2 ways to do useful things; those connections are made by turning on single transistors (by writing data into an on-chip RAM).
Possibly. You'll definitely have latches and D flip-flops, as well as muxes and more complex gates like various AND-OR-invert (NAND and NOR are just special cases of AND-OR-invert). Somewhat, but it's even more expensive in interconnect between the gates.Admin
Yeah, people forget that transmission gates (aka analog switches or pass gates) are just as fundamental a CMOS element as NAND or NOR gates are...
Admin
Computers aren't especially good at computing anyway. A computer is all about transferring and jamming bits (even a shift register is quite dramatic). The adder used to be one of the most expensive pieces of hardware before there were microprocessors.
(Interestingly, computing by discrete elements would be easier using ternary logic. The Russians did it with some success, see: "Development of ternary computers at Moscow State University" http://www.computer-museum.ru/english/setun.htm. Using ternary logic OR becomes a max-function and AND becomes a min-function on the bits involved. Using it for arithmetics, there are no rounding errors and it allows arbitrary word lengths of the arguments. Also, its arguably faster and there are less — and cheaper! — elements involved. Some believed it to be the inevitable future of computing in the 1950s.)