Charles Mills wrote: > > This should be (int won't work on most/all 64 bit systems): > static ID id_push; > > Read the man page for sin. Basically obj is a reference to a Ruby > Object not a double, so you need to go from a Ruby object to a double > here. Best way is > obj = rb_Float(obj); Actually this produces an incorrect answer for sin. > - or - > obj = rb_convert_type(obj, T_FLOAT, "Float", "to_f"); > then you can get treat obj as a T_FLOAT and cast it to a struct RFloat* > and get the value like so: > double sin_of_obj = sin(RFLOAT(obj)->value); > > Finally you can create a new float from the result of sin() using > rb_float_new(sin_of_obj). This produces the correct answer > I think all of the errors in your code would be caught be compiler > warnings, perhaps use -Wall / -W. > I'm compiling this on a WindowsXP. and received NO compiler warnings on my code. Which led to my befuddled state. > -Charlie > Thanks for your help. My confusion resulted from trying to use the Math module in Ruby. I hadn't seen anything anywhere that describes how to do this. Looking at Math.c it looks like it returns a VALUE type (ruby struct or union). What you provided calls the sin function in math.h. This works fine. I thought I was calling math_sin. If you look at the Math_init() function it aliases the math_sin function in Math.c as "sin" with 1 argument. However, (this is where I become confused) the math_sin function seems to require 2 inputs not one. Although your solution certainly solves my problem, I'm still confused about using the math module itself. Thanks again, Ernie