Re: [avr-gcc-list] Rounded integral division in preprocessor

2010-02-05 Thread Bob Paddock
On Fri, Feb 5, 2010 at 1:44 AM, Johannes Bauer jb@gmx.de wrote: Dear list, I'm trying to do rounded (opposed to truncated) integer division with avr-gcc with using only preprocessor magic. This proves to be difficult: The current code I'm using is #define __IDIV(x, y)    (long)(((long)x

RE: [avr-gcc-list] Rounded integral division in preprocessor

2010-02-05 Thread Dave Hansen
From: jb@gmx.de: I'm trying to do rounded (opposed to truncated) integer division with avr-gcc with using only preprocessor magic. This proves to be difficult: The current code I'm using is #define __IDIV(x, y) (long)(((long)x + ((long)y / 2L)) / (long)y) #define IDIV(x, y)