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
Message
RE: [AVR-Chat] some C string conversion functions?
2005-04-22 by Paul Curtis
Attachments
- No local attachments were found for this message.