Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] some C string conversion functions?

2005-04-22 by Paul Curtis

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.