Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Steve Thompson Newsgroups: comp.lang.c Subject: Re: Code for strtol/strtoul Date: Fri, 27 Mar 2015 15:02:13 +0000 Organization: Friends of the Galactic Collective Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="dfca600df3027c25a5e3889f25105c66"; logging-data="6706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wdmxbaQWp893QYKP33imN" User-Agent: NN 6.4.3 Cancel-Lock: sha1:u7j+3mZUJv0pR1CjsZfYkPY8CXc= Xref: csiph.com comp.lang.c:59086 On Wed, Mar 25, 2015 at 10:43:49PM +0100, jacob navia wrote: > Th code posted doesn't handle the case: > > 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005 > > Since I have a max length, I missed this case. I have fixed it, will > post the fix later I'm surprised no-one has suggested that he use a textual number representation that has some sort simple RLL compression. That also makes it much more efficient to do strlen() on average because the char array will often be so much shorter if numbers like the above are at all common in the program input. Regards, Steve Thompson -- "If I had a nickel for every time some idiot called me about a computer problem that turned out to be user error, I would be able to retire and spend the rest of my days cultivating clues in my backyard hillside garden." -- MysteryDog in 24hoursupport.helpdesk.