Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / January 2006



Tip: Looking for answers? Try searching our database.

Math functions mysteriously returning zero

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Xcott Craver - 14 Jan 2006 03:02 GMT
Hi,

I'm writing a plugin (Cocoa bundle) for a Cocoa application in Xcode.
The plugin is given two arrays of doubles, and computes out[i]=sin(in[i]);

I graph this data in the main application, and verify that the actual
data handoff works just fine.  For example, if I code "out[i]=in[i]"
the that gets transferred after the plugin is invoked.

Here's the goofy part:  when I put the sin() in there, out[i] is 0.0.
The function is just returning 0s.  Ditto for other math functions like
cos(), exp(), etc.

Now, I include math.h, and I added -lm to the linker, and I
explicitly declare "double sin(double x);" in my plugin code.  I
don't get any linker errors or warnings---everything compiles and links
fine.  But the sin() function just returns 0.0.  

I'm really pulling my hair out over this.  Anyone have any idea what I
should try?  Again, this is not a Cocoa application, but a cocoa bundle.
Could that have something to do with it?

Thanks,
Xcott
Signature

"Old country music stars don't die -- they just get put in a coffin and buried
in the ground and then no one sees them ever again."
                                                               --Cat and Girl

Xcott Craver - 14 Jan 2006 03:50 GMT
>Hi,
>
>I'm writing a plugin (Cocoa bundle) for a Cocoa application in Xcode.
>The plugin is given two arrays of doubles, and computes out[i]=sin(in[i]);

    Um, nevermind, I figured it out.

    In case you're wondering, it was a really, really stupid mistake.  
    I forgot that the scale on the graph was in the tens of thousands,
    and of course sin(anything) is between -1 and 1.  So it just looked
    like no data was coming out.
   
    YEESH.

Signature

"Old country music stars don't die -- they just get put in a coffin and buried
in the ground and then no one sees them ever again."
                                                               --Cat and Girl

Simon Slavin - 16 Jan 2006 22:15 GMT
On 14/01/2006, Xcott Craver wrote in message
<2y_xf.99573$ME5.7430@twister.nyroc.rr.com>:

>     Um, nevermind, I figured it out.
>
[quoted text clipped - 4 lines]
>    
>     YEESH.

Thanks for that entertainment.  I've done just a silly things myself, and
am reassured to know that others are doing that too.

Simon.
Signature

http://www.hearsay.demon.co.uk

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.