|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: Some trig trouble -- and IEEE floating point format
In a message dated 9/5/00 2:02:53 PM Central Daylight Time,
lionelp@worldonline.co.za writes:
<< double angle_rad, sine;
angle_rad = angle_deg * M_PI / 180.0;
sine = sin(angle_rad);
printf("The sine of %.2f is %.8f.\r\n", angle_deg, sine);
If I try to run this code, I get "Floating point error: Domain.", >>
Hmmm, nothing jumps out at me, but are you sure angle_deg is a valid number?
Basically, if you plot the sine graph (x = value, y=sin(value)) the x values
are considered "domain" and the y values are considered "range." So, the
numbers you feed the sin() function make up the domain, and the results you
receive make up the range. Therefore, this error means something is wrong
with angle_deg. Is angle_deg a double as well? How about M_PI? Usually when I
get a Domain error, I set up the formula wrong (180/(pi*degree)) instead of
(pi*degree)/180. But that isn't what's wrong. Check to make sure angle_deg
isn't an integer. If it is, this should work:
angle_rad = (double)angle_deg * M_PI / 180.0;
Or I could be missing the error entirely.
-Ender Wiggin
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once
To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
|
|