Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: some C string conversion functions?

2005-04-22 by arhodes19044

Thanks for pointing me to the div functions.  I believe I will be 
always working with positive numbers, but I have not finalized that 
part of the work.  I will have to see how it evolves.  Right now I 
am getting up to speed on the use and programming of the ATmega128.  
Then get back into C (it is almost like riding a bike), then I will 
actually write the software.  It is actually pretty simple 
software.  I just have to be sure never to have the off-by-one 
error, and there are MANY MANY ways to get this error in complex 
timing and 

-Tony

--- In AVR-Chat@yahoogroups.com, "Paul Curtis" <plc@r...> wrote:
> Robert et al, 
> 
> > At 02:18 PM 4/22/05 +0000, arhodes19044 wrote:
> > >I see the modulo function for floats, but is there an 
> > integer version 
> > >of modulo?  I did not see that.
> > 
> > %
> 
> % is indeed the integer modulus (remainder after division) 
operator, but
> implementations are allowed to implement this using either 
symmertic or
> floored division.  This is only a problem if you use '%' with 
integer
> operands which could possibly be negative.  In that case, two C
> implementations could produce different results on the SAME 
processor.
> 
> In order to get a guaranteed-consistent remainder after division, 
the C
> library provides div, ldiv and (optionally) lldiv functions that 
have a
> DEFINED quotient and remainder that is the same for every C
> implementation irrespective of processor or underlying division
> opcode/algorithm.
> 
> Regards,
> 
> --
> Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.