[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
fungus <fungus@egg.chips.and.spam.com> wrote:
>
>
>Gene Wirchenko wrote:
>>
>>
>> >3. "Write a function to print out a 32-bit number in decimal, but in
>> >reverse."
>>
>> I like this one. Again, there are platform considerations.
>>
>
>Not really, just use unsigned longs.
I believe it would be a conforming implementation of C to have
short, int, and long all be 16 bits. In that case, using unsigned long
wouldn't be enough.
>Anyway, in reverse order is the easy case. Printing the number
>in forward order requires a lot more twiddling.
Start filling the string at the far end of a space wide enough to
hold the longest possible value. Decrement the pointer as you
generate the digits and return the pointer pointing to the first
character.
>(Assuming we're not using the standard library here...)
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
- References:
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: "Bob Headrick" <bobh@proaxis.com>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: mzenier@netcom.com (Mark Zenier)
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: bill_h <bill_h@sunsouthwest.com>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: Charles Richmond <richmond@plano.net>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: jschmitz@qis.net (JoAnne Schmitz)
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: rmk@toad.rmkhome.com
- not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: Eric Smith <eric-no-spam-for-me@brouhaha.com>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: Charles Eicher <ceicher@inav.net>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: brucehoult@pobox.com (Bruce Hoult)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: hshubs@mindspring.com (Howard S Shubs)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: "Ian St. John" <istjohn@spamcop.net>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: prs@gol.com (Peter Stephenson)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: gillies@cs.ubc.ca (Donald Gillies)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: genew@shuswap.net (Gene Wirchenko)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: fungus <fungus@egg.chips.and.spam.com>