• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: std::log10() problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: std::log10() problem


  • Subject: Re: std::log10() problem
  • From: Paul Miller <email@hidden>
  • Date: Thu, 30 Mar 2006 18:14:12 +0100

<snip>
What doesn't make sence to me is why things as std::log10() that's been part
of the standard C++ Library since 1999(?)
doesn't work as it should?
Same if you call some other <cmath> stuff as std::sin() with a float value
instead of a double.

I also tried to link with libstdc++.a from the 10.3.9 or 10.2.8 SDK, makes
no difference.

I'm building my app on an Intel Mac, haven't tried on my PPC with 10.4.0 SDK
instead of 10.4u
That might work??

It's easy to test thos things by just building a default Carbon application
with Xcode and then just
add say:

double dVal = std::log10(float(1.0));    // doesn't work with SDK 10.4u

double dVal = std::log10(double(1.0));    // work OK with SDK 10.4u

Thanks

Rolf


What seems to have happened is that 10.4 has added some new optimisations for float precision math in the C++ headers for GCC 3.3
When you compile std::log10( (float)1.0) with the 10.2.8 C++ headers, it ends up calling log10
When you compile std::log10( (float)1.0) with the 10.4 C++ headers, it ends up calling log10f 

log10f (and friends e.g. powf, sinf etc.) are not implemented in the 10.2.8 version of libstdc++, so you get the error.

<cmath> looks like this:

#if _GLIBCPP_HAVE_LOG10F
  inline float 
  log10(float __x) { return ::log10f(__x); }
#else
  inline float 
  log10(float __x) { return ::log10(static_cast<double>(__x)); }
#endif

I'm guessing that _GLIBCPP_HAVE_LOG10F shouldn't be defined if you are targeting 10.2.8. c++config.h doesn't look as if it defines it - anyone know where it is getting set?

I got around the problem by casting the parameters to all my math calls to double (messy).

- Paul Miller
AVA CAD/CAM.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: what's supposed to get stripped?
  • Next by Date: Re: fnfErr for resource files
  • Previous by thread: Re: std::log10() problem
  • Next by thread: Strange Behavior With Variable Names
  • Index(es):
    • Date
    • Thread