Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Beginner....Decimal/Octal converter help
Date: Sun, 11 Sep 2022 07:07:26 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <86zgf6ovhd.fsf@linuxsc.com>
References: <8ffd982c-2e82-4caa-9256-ec17be2efe56n@googlegroups.com> <86leqsr091.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="eacead3a04a98f103c487ee10dc191dc"; logging-data="2034517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JY6hcoo3zcuiZKxeeD0RRr6YNhZMWytY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:PIq3ecOUzOX6BD0jwuTmGH96pEA= sha1:Dl8Uch7eeWy5LLeNZUj2GoKY6yk=
Xref: csiph.com comp.lang.c:167603
scott@slp53.sl.home (Scott Lurndal) writes:
> Tim Rentsch writes:
>
>> ManyBeers writes:
>>
>>> Hello I am teaching myself C and I need some help with a problem.
>>> After a search for dec/oct convert I found this code:
>>>
>>> [..code..]
>>
>> I would like to offer a different kind of answer to your
>> questions. First a suggestion: for this kind of problem I think
>> you will find it helpful to use unsigned types exclusively. In
>> the code below we will need (besides a plain 'unsigned' here and
>> there) two types, one for 8-bit values and one for 32-bit values:
>>
>> typedef unsigned char UC;
>> typedef unsigned int UI;
>
> There already standard perfectly cromulent typedefs for both,
> uint8_t and uint32_t.
For the posted response and example I think unsigned {char,int}
are better suited.
Furthermore, whether cromulent or not, IMO anyone who writes
uint8_t or uint32_t in open code should be shot.[*] YMMV.
[*] For more information please refer to the PDP-10 assembly
language style guide.