Re: [PATCH v3] linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative operands

2012-08-30 Thread Guenter Roeck
On Thu, Aug 30, 2012 at 05:35:31PM -0700, Andrew Morton wrote: > On Thu, 30 Aug 2012 17:10:47 -0700 Guenter Roeck wrote: > > > DIV_ROUND_CLOSEST returns a bad result for dividends with different sign: > > DIV_ROUND_CLOSEST(-2, 2) = 0 > > > > Most of the time this does not matter. However, in

Re: [PATCH v3] linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative operands

2012-08-30 Thread Andrew Morton
On Thu, 30 Aug 2012 17:10:47 -0700 Guenter Roeck wrote: > DIV_ROUND_CLOSEST returns a bad result for dividends with different sign: > DIV_ROUND_CLOSEST(-2, 2) = 0 > > Most of the time this does not matter. However, in the hardware monitoring > subsystem, DIV_ROUND_CLOSEST is sometimes used

[PATCH v3] linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative operands

2012-08-30 Thread Guenter Roeck
DIV_ROUND_CLOSEST returns a bad result for dividends with different sign: DIV_ROUND_CLOSEST(-2, 2) = 0 Most of the time this does not matter. However, in the hardware monitoring subsystem, DIV_ROUND_CLOSEST is sometimes used on integers which can be negative (such as temperatures). Signed