[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?

From: David Brown
Subject: Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?
Date: Tue, 20 Sep 2005 09:41:54 +0200

> On Monday 19 Sep 2005 17:11, David Brown wrote:
> >...
> Nice code.
> My other solution would be to put the powers of ten in an array and
> compare them instead of doing the division, but I think your code will
> probably be faster.
> It might be possible to merge the two methods and put your bit patterns
> and increments in a constant structure, and then iterate over them. For
> smaller code size with marginal speed penalty.
> --
> Richard Urwin

It's possible that putting the patterns in a structure might save a small
amount of code, but I think not noticably for the three-digit case, and it
would be at least twice as slow (you'd have to do a lot more 16-bit
arithmetic).  If you wanted to extend the idea to, say, 5 digits, then
that's a different matter - you'd get smaller code, and marginal speed
penalty since you need to do 16-bit arithmetic anyway (it's important to
note that the "lo" byte never overflows).  Maybe it would be interesting to
re-implement utoa using that method.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]