delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/12/01:38:30

Date: Fri, 11 Jul 1997 22:36:30 -0700 (PDT)
Message-Id: <199707120536.WAA15679@adit.ap.net>
Mime-Version: 1.0
To: dgmdavies AT onaustralia DOT com DOT au
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: math.h sin() function returns wrong value
Cc: djgpp AT delorie DOT com

You wrote:
>[deleted, but includes lines such as:]
>  printf("sin(45) = %f\n", sin(45));
>If I enter 32 as the angle, the
>converted angle is 45, which is right, and then when I call the sin()
>function I get a completely different answer.  
The sin() function takes its arguments in *radians*. If you don't know what
radians are, read on.
Radians are an angle measuring unit, there are (2*PI) radians in a full
circle (360 degrees). Thus, here are some macros for converting between the two:
#define degtorad(x) (((double)x / 360) * (2 * PI)) /* PI defined in math.h */
#define radtodeg(x) (((double)x / (2 * PI)) * 360)

>Do I need to get djgpp version 3?  At the moment, I've got version 2.
Version 3 does not exist yet. The newest version is 2.01.

HTH

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019