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

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

Re: [avr-libc-dev] [bug #23677] Request for cbrt() and strdup to be adde


From: Russell Shaw
Subject: Re: [avr-libc-dev] [bug #23677] Request for cbrt() and strdup to be added to libc
Date: Mon, 23 Jun 2008 13:27:39 +1000
User-agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110)

Russell Shaw wrote:
Andy Hutchinson wrote:
URL:
  <http://savannah.nongnu.org/bugs/?23677>

Summary: Request for cbrt() and strdup to be added to libc
                 Project: AVR C Runtime Library
            Submitted by: hutchinsonandy
            Submitted on: Sunday 06/22/2008 at 21:51
                Category: Feature Request
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: libc code
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: Any
           Fixed Release: None

    _______________________________________________________

Details:

It seems gcc testsuite assumes presence of widely available strdup() and
cbrt() functions.

strdup is a derivative of malloc
cbrt is cubic root x^(1/3)
Here are some generic version that can be used as starter.
I'm sure someone can trim them up a bit - or even convert to asm.

Best version depends on how we built existing maths  functions.

double cbrt(const double x)

{
return pow(x,1.0/3.0);
}

OR

double cbrt(const double xx)
{
   double x= xx;
   if  (x==0.0) /* log will fail, but answer is easy */
      return 0.0;
   else if  (x>0.0)
       return(exp(log(x)/3.0));
   else
   x= -x;
      return(exp(log(x)/3.0));
  }

I *never* use straight fp equality in code (x==0.0 baaad).

http://c-faq.com/fp/fpequal.html
http://c-faq.com/fp/strangefp.html

I suppose it's ok for this case. It's only checking that
log(x) doesn't go infinite. I'm very slow early in the day.




reply via email to

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