• 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: problem with cos ( pi/2 )
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with cos ( pi/2 )


  • Subject: Re: problem with cos ( pi/2 )
  • From: Tommy Nordgren <email@hidden>
  • Date: Sun, 18 Jun 2006 18:33:14 +0200


On 16 jun 2006, at 17.07, billmonk wrote:

Not sure if this is the right list...searching it hasn't turned up any likely entries...


When calling cos( pi/2 ), I'm getting a tiny number, rather than zero, for


cos( M_PI_2 ); // pi/2, 1.57079632679489661923 from <math.h>


pi/2 is not an exactly representable number in floating point binary. (not in any base in fact)
The only way to get the Mathematical result is by a symbolic math package.
However the deviation appears about one order of magnitude too big, since it IS possible
to represent pi/2 with an accuracy of about 1e-16
I've added "-llibm" to "Other C flags", as alluded to here,

http://developer.apple.com/documentation/Darwin/Reference/ManPages/ man3/intro.3.html

but am still getting 2.6484540326036093e-14 instead of 0.


My old IM:PowerPC Numeric book, and the OS X pdf here

http://developer.apple.com/documentation/Performance/Conceptual/ Mac_OSX_Numerics/Mac_OSX_Numerics.pdf

say cos( pi/2 ) is a special case (for all the reasons given in PPCNumerics) but that an IEEE-compliant math lib should return -0.0, with the "inexact" flag set, for cos( pi/2 ).

So it looks like I'm not actually using the IEEE libm. What am I doing wrong?

As a data point, I notice Calculator.app in Degrees mode correctly gives 0 for cos( 90 ), but in Radians mode gives a tiny number for cos ( pi /2 ); a different one than I get for cos( M_PI_2 ). That's kind of weird...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40chello.se


This email sent to email@hidden

------------------------------------------------------ "Home is not where you are born, but where your heart finds peace" - Tommy Nordgren, "The dying old crone" email@hidden


_______________________________________________ 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
  • Follow-Ups:
    • Re: problem with cos ( pi/2 )
      • From: "Mark Wagner" <email@hidden>
References: 
 >problem with cos ( pi/2 ) (From: billmonk <email@hidden>)

  • Prev by Date: Re: problem with cos ( pi/2 )
  • Next by Date: Re: Debug Configuration Linking
  • Previous by thread: Re: problem with cos ( pi/2 )
  • Next by thread: Re: problem with cos ( pi/2 )
  • Index(es):
    • Date
    • Thread