Do the trig functions in math.h work in degrees, radians or what? For
some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1)
return 45 or .7something (degrees or radians) instead of some negative
number?
--
Mark Healey
marknews(at)hea leyonline(dot)c om 7 3142
Mark Healey <di*@spammer.di e> writes: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
If on a Unix/Linux system - man 3 sin
--
Chris.
On Sun, 21 May 2006 03:43:36 GMT, Mark Healey <di*@spammer.di e> wrote
in comp.lang.c: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
Doesn't your C reference book tell you? All C trigonometric functions
work in radians. If you want to work in degrees, you need to provide
functions or macros to do the conversions back and forth.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Mark Healey <di*@spammer.di e> writes: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
Some negative number?
This program:
#include <stdio.h>
#include <math.h>
int main(void)
{
printf("atanf(( float)1.0) = %f\n", atanf((float)1. 0));
return 0;
}
gives me:
atanf((float)1. 0) = 0.785398
Did you remember the "#include <math.h>"? Did you make sure to link
in the math library (on a Unix-like system, you might need a "-lm"
option).
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org... Mark Healey <di*@spammer.di e> writes: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
Some negative number?
This program:
#include <stdio.h> #include <math.h> int main(void) { printf("atanf(( float)1.0) = %f\n", atanf((float)1. 0)); return 0; }
gives me:
atanf((float)1. 0) = 0.785398
Did you remember the "#include <math.h>"? Did you make sure to link in the math library (on a Unix-like system, you might need a "-lm" option).
And would atanf be in there, in particular one that accepts a float as
opposed to double? joe
"Joe Smith" <gr**********@n etzero.net> writes: "Keith Thompson" <ks***@mib.or g> wrote in message news:ln******** ****@nuthaus.mi b.org... Mark Healey <di*@spammer.di e> writes: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
Some negative number?
This program:
#include <stdio.h> #include <math.h> int main(void) { printf("atanf(( float)1.0) = %f\n", atanf((float)1. 0)); return 0; }
gives me:
atanf((float)1. 0) = 0.785398
Did you remember the "#include <math.h>"? Did you make sure to link in the math library (on a Unix-like system, you might need a "-lm" option).
And would atanf be in there, in particular one that accepts a float as opposed to double? joe
Possibly not, since atanf was added in C99 -- but if atanf weren't in
the library, that wouldn't explain the OP's result of "some negative
number".
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org... "Joe Smith" <gr**********@n etzero.net> writes: "Keith Thompson" <ks***@mib.or g> wrote in message news:ln******** ****@nuthaus.mi b.org... Mark Healey <di*@spammer.di e> writes: Do the trig functions in math.h work in degrees, radians or what? For some reason it doesn't say which in "man math.h"
IIRC the arctan of a slope gives the angle. So, shouldn't atanf((float)1) return 45 or .7something (degrees or radians) instead of some negative number?
Some negative number?
This program:
#include <stdio.h> #include <math.h> int main(void) { printf("atanf(( float)1.0) = %f\n", atanf((float)1. 0)); return 0; }
gives me:
atanf((float)1. 0) = 0.785398
Did you remember the "#include <math.h>"? Did you make sure to link in the math library (on a Unix-like system, you might need a "-lm" option).
And would atanf be in there, in particular one that accepts a float as opposed to double? joe
Possibly not, since atanf was added in C99 -- but if atanf weren't in the library, that wouldn't explain the OP's result of "some negative number".
I'm surprised that my implementation, circa ten years old, has it. joe
#ifdef _M_MRX000
/* MIPS fast prototypes for float */
/* ANSI C, 4.5 Mathematics */
/* 4.5.2 Trigonometric functions */
_CRTIMP float __cdecl acosf( float );
_CRTIMP float __cdecl asinf( float );
_CRTIMP float __cdecl atanf( float );
_CRTIMP float __cdecl atan2f( float , float );
_CRTIMP float __cdecl cosf( float );
_CRTIMP float __cdecl sinf( float );
_CRTIMP float __cdecl tanf( float );
Joe Smith wrote: "Keith Thompson" <ks***@mib.or g> wrote in message news:ln******** ****@nuthaus.mi b.org... "Joe Smith" <gr**********@n etzero.net> writes: "Keith Thompson" <ks***@mib.or g> wrote in message news:ln******** ****@nuthaus.mi b.org... Mark Healey <di*@spammer.di e> writes: > Do the trig functions in math.h work in degrees, radians or what? For > some reason it doesn't say which in "man math.h" > > IIRC the arctan of a slope gives the angle. So, shouldn't > atanf((float)1) > return 45 or .7something (degrees or radians) instead of some negative > number? Some negative number?
This program:
#include <stdio.h> #include <math.h> int main(void) { printf("atanf(( float)1.0) = %f\n", atanf((float)1. 0)); return 0; }
gives me:
atanf((float)1. 0) = 0.785398
Did you remember the "#include <math.h>"? Did you make sure to link in the math library (on a Unix-like system, you might need a "-lm" option). And would atanf be in there, in particular one that accepts a float as opposed to double? joe Possibly not, since atanf was added in C99 -- but if atanf weren't in the library, that wouldn't explain the OP's result of "some negative number". I'm surprised that my implementation, circa ten years old, has it. joe
#ifdef _M_MRX000
/* MIPS fast prototypes for float */ /* ANSI C, 4.5 Mathematics */
/* 4.5.2 Trigonometric functions */
_CRTIMP float __cdecl acosf( float ); _CRTIMP float __cdecl asinf( float ); _CRTIMP float __cdecl atanf( float ); _CRTIMP float __cdecl atan2f( float , float ); _CRTIMP float __cdecl cosf( float ); _CRTIMP float __cdecl sinf( float ); _CRTIMP float __cdecl tanf( float );
The math functions for float data type were reserved and made optional
in C89, and mandatory in C99. This seems to have produced some
confusion as to whether restricting a compiler to C89 mode, (gcc
default), may suppress the float functions, or break them, as in some
MSVC versions. Clearly, the provision for them in C89 was produced by
strong demand and intention of certain vendors to provide them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frank Millman |
last post by:
Hi all
I was helping my niece with her trigonometry homework last night. Her
calculator's batteries were flat, so I thought I would use Python's
math module to calculate sin, cos, and tan.
I tried the example in the text book first, to ensure that I was
getting the correct result, but it did not agree. Then my wife had the
idea of using the Microsoft calculator in scientific mode, and that
one did give the correct result.
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time
you cycle through the nest of loops. Using a HD for storage to extend
ram is much too slow for many...
|
by: John B. |
last post by:
I'm self teaching myself C on a Linux box but I can't get a simple program
to recognize math functions. I start the program with:
#include <stdio.h>
#include <math.h> but when I compile the program, it does not
recognize sin(x); or pow(x,y) etc, in any equation.
/usr/include does have a math.h file. Any help or things to try would
be greatly appreciated!!!!. (I do alot of graphic things with trig.)
thanks ...
|
by: Dave Rudolf |
last post by:
Hi all,
Normally, I would trust that the ANSI libraries are written to be as
efficient as possible, but I have an application in which the majority of
the run time is calling the acos(...) method. So now I start to wonder how
that method, and others in the math.h library, are implemented.
Dave
|
by: Tom Gurath |
last post by:
http://osnews.com/story.php?news_id=5602&page=2
This benchmark tests the Math & File I/O of 9 languages/run-times.
Visual C++ (Version 7 - not managed)
Visual C#
gcc C
Visual Basic.NET
Visual J#
Java 1.3.1
Java 1.4.2
| |
by: Gregory Pietsch |
last post by:
I'm writing a portable implementation of the C standard library for
http://www.clc-wiki.net and I was wondering if someone could check the
functions in math.h for sanity/portability/whatever. I'm almost halfway
through writing the over 200 functions needed to implement C99's
version of math.h, and I would like to have some feedback and/or expert
advice on my implementations.
Sincerely, Gregory Pietsch
|
by: Morgan Cheng |
last post by:
Hi,
I am writing a program that will take a lot of Math.Cos & Math.Sin
operation. I am afraid this will be source of performance impact.
Anybody knows how Math.cos & Math.Sin is implemented?
I suppose it just retrieving a huge pre-computed table, it might be
quick. I tried to cache all possible angle cos/sin in my own array , it
turns to be much faster to call Math.Cos & Math.Sin all the time.
|
by: kirby.urner |
last post by:
Cyber-curricula have a leveling aspect, as kids
nearer Katrina's epicenter tune in and bliss out
on 'Warriors of the Net' (why wait for stupid big
dummy textbooks to catch up?). They feel more
empowered by Python and Ubuntu than by any
King's English I'd warrant, given how the latter
has been dumbed down (slowed, degraded) by
unimaginative bankers who can't fathom open
source and its math-teaching significance to
our digitally savvy...
|
by: Jon Harrop |
last post by:
xahlee@gmail.com wrote:
This does not even start running in Mathematica 6, let alone produce any
correct results. The first line was deprecated some time ago. I don't know
what is wrong with the rest of your program but it takes a while to produce
the empty list.
Then your program should produce an infinite number of terms, e.g. x,
Sin, Sin], ...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |