avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] pow(x,y) broken for x<0


From: Edwin Olson
Subject: [avr-libc-dev] pow(x,y) broken for x<0
Date: Mon, 24 Oct 2005 15:50:50 -0400
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

Hi folks,

I believe the implementation of pow is inconsistent with the standard POSIX definition. The one provided by avr libc assumes x>0 so that it can approximate x^y with exp( log(x) * y).

The POSIX definition allows x<0, provided that y is integral valued.

In my case, I was computing a euclidean distance ((x1-x0)^2 + (y1-y0)^2), using pow for no good reason, but it crashed the atmel with an apparant stack overflow. (Presumably log(x) is ill-behaved for x<0).

x<0 could be relatively easily handled with a little wrapper which computes pow (abs(x), y) * (-1 if y is odd).

Thanks,

-Ed





reply via email to

[Prev in Thread] Current Thread [Next in Thread]