Well, a little more than 32 (unless you count a full adder as one gate? but I wouldn't). Especially if you use any type of fast adder which is often mandatory to hit frequency targets. Subtraction doesn't cost much extra, you can reuse your adder by turning it into an adder-subtractor. Comparisons don't cost extra, comparison is subtraction. Multipliers are bigger.
So it costs a few more gates than you estimated, but also there are far more transistors: billions, these days.
(Scalar) ALUs are not a big part of a modern high-performance CPU, even after accounting for there being a handful of them (I mean multiple per core, of course there are usually multiple cores too). Here's a fun article showing how big various parts of a CPU actually are, keep in mind it's showing a super obsolete Pentium 4: Intel’s Netburst: Failure is a Foundation for Success – Chips and Cheese
Not that recent. The 8008 used carry lookahead for example. And several 74181 (a 4-bit ALU chip which you can use multiple of in a group to build a wider ALU) could be combined with the 74182 (lookahead carry generator) to build an ALU with carry lookahead. These things are ancient (70's era tech).
That does not mean that carry lookahead addition was always used everywhere, some chips were really trying to save on transistors and didn't use it. But anything modern, probably has some sort of fast adder. Ripple carry adders do not scale well (imagine a 64-bit ripple carry adder, yikes) and transistors are significantly cheaper than a dime a dozen.
PIEBALD pulls his copy of Code by Charles Petzold off the shelf behind him.
Chapter Twelve describes implementing A Binary Adding Machine from simple logic gates.
His descriptions of logic gates use relays rather than transistors.
I haven't counted, but it looks like a simple 32-bit adder built according to his diagrams might require a bit more than a hundred relays?
Question about the Switch Case, I always treated the default section of a switch case a 'I have no idea what to do'
for(i=0; i<= 100; i++)
val = myServo.read();
What appears to be happening it goes to the default when not caught by a catch. In the example when i = 50,
I need a method for catching values out side of the the range 1 to 100. As if the servo returns value outside of the range 0 to 100. Could I do with an if... if(( i < 0) && (i >100)) would this take care of anything 0 - 100??? I will try that.
In your instance (if this is the actual code), all values that are not 0, 50, or 100 will end up at the default statement. There's also a missing closing bracket for the switch statement, probably a copy/paste thing.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
... oops (wrong forum red-flag-accessed-by-moi)
For some reason I thought I was in the Lounge and have disappropriated some points that shouldn't be mine. Sorry!
Is "What do I do now" an appropriate C/C++/MFC question?
Thanks (answered myself),
It was a need to think carefully, code blindness issue. I knew if I posted it the lounge I would get cruified by all and sundry needed somewhere to write think and take notice of the abortion I has created.
I am a dummy, I should have seen the problem, in fact I did as I was writing the question. I helps writing out the problem to see it more clearly, You can see the light starting to dawn in the last sentance problem solved.
Boolean gates are not type of transistor but rather cluster of transistors. Is that so? For example the schematic representation of the Not gate has just one line in one line out. A transistor means there is a high voltage line in high voltage line out, low voltage line in low voltage line out. Is the schematic representation showing only the relevant ins and outs?