> 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.



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to