[NSRCA-discussion] Chapter-12 computer science.
Martin X. Moleski, SJ
moleski at canisius.edu
Wed Jul 4 05:28:53 AKDT 2007
Matthew Frederick wrote:
> Well, num increments before cnt does, so num would reach 256 as well ...
I don't have a C compiler to play with and it's been ~20 years
since I did.
Arguing from pseudo-language, I read the function as saying,
"If the counter is less than 256, then increment the number by one.
Increment the counter and repeat the if-then branch until the
count is equal to 256."
I can write the function in other languages than C (Pascal,
PHP, Javascript; I threw away my assembly-language books with
a sigh this year, so I probably couldn't come up with
working code, but back in the 80s I monkeyed around with
some assembly language for a couple of projects.
> ... I still don't like the example, I hate the thought of
> using characters for numbers.
The bits are all the same. The question is how we want
to interpret them: -127, 0xFF, chr(255), 255. It's an
amazing system.
> ... Just seems silly to me. Then again, it's the
> exact kind of thing my old computer science teacher would have put on a test
> just to mess with everyone. Then again he would throw something in there
> that looked like nothing but a string of ampersands and asterisks with a
> one-letter variable at the end and ask if it was a pointer or not... he was
> kind-of nuts.
Yup. I've seen those kinds of challenges. I can't
make heads or tails of them. I got hooked on Turbo
Pascal when it first came out and have had trouble
reading C and its derivatives for a long time. I'm
making a little progress nowadays.
Marty
More information about the NSRCA-discussion
mailing list