473,513 Members | 6,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Result of sin function differs?

asd
Hello all.

I was doing some kind of development and in the test file I have something
like this:

///// Test File /////
double x = sin(45);

The output for that statement is:

///// Output Test File /////
0.707107
Unfortunately the output in my system differs from the one in the test
file.

I run the following example in my system:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << sin(45) << endl; // prints 0.850904

return 0;
}

The example above prints 0.850904 in my system. In addition to that, my
calculator says sin(45) is 0.707107, while calculator at google says that
it is 0.850904.

I am just curious if I am doing something wrong.
Thanks a lot.
Mar 24 '07 #1
8 2999
sin(45 degree) is approximately 0.707107,
sin(45 in radian) is approximately 0.850904.

My 2 cents.

Stephen Wong @ Hong Kong

On Sat, 24 Mar 2007, asd wrote:
Hello all.

I was doing some kind of development and in the test file I have something
like this:

///// Test File /////
double x = sin(45);

The output for that statement is:

///// Output Test File /////
0.707107
Unfortunately the output in my system differs from the one in the test
file.

I run the following example in my system:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << sin(45) << endl; // prints 0.850904

return 0;
}

The example above prints 0.850904 in my system. In addition to that, my
calculator says sin(45) is 0.707107, while calculator at google says that
it is 0.850904.

I am just curious if I am doing something wrong.
Thanks a lot.
Mar 24 '07 #2
asd wrote:
Hello all.

I was doing some kind of development and in the test file I have something
like this:

///// Test File /////
double x = sin(45);

The output for that statement is:

///// Output Test File /////
0.707107
Unfortunately the output in my system differs from the one in the test
file.

I run the following example in my system:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << sin(45) << endl; // prints 0.850904

return 0;
}

The example above prints 0.850904 in my system. In addition to that, my
calculator says sin(45) is 0.707107, while calculator at google says that
it is 0.850904.
You are confusing different ways of measuring angles. A half of a right
angle can be specified as 45 deg or as Pi/8 rad. In the above computations,
the number 45 sometimes is interpreted as deg and sometimes as rad.
Best

Kai-Uwe Bux
Mar 24 '07 #3

"asd" <no****@nospam.comwrote in message
news:pa****************************@nospam.com...
Hello all.

I was doing some kind of development and in the test file I have something
like this:

///// Test File /////
double x = sin(45);

The output for that statement is:

///// Output Test File /////
0.707107
Unfortunately the output in my system differs from the one in the test
file.

I run the following example in my system:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << sin(45) << endl; // prints 0.850904

return 0;
}

The example above prints 0.850904 in my system. In addition to that, my
calculator says sin(45) is 0.707107, while calculator at google says that
it is 0.850904.

I am just curious if I am doing something wrong.
This program should explain.

#include <cmath>
#include <iostream>
#include <string>

const double pi = 3.1415926;

int main()
{
double degrees = 45.0;
// There are 2 pi radians in a circle.
// There are 360 degrees in a circle.
double radians = ( 2.0*pi) / 360.0 * degrees;

// std::sin expects input as radians
std::cout << std::sin( radians ) << "\n";

std::string wait;
std::getline( std::cin, wait );

}
Mar 24 '07 #4
asd
Thank you so much for all of your answers.

Now I am struggling with asin.

the test file has:
asin(.5);

// test output
30

// My output with radian conversion
0.00872676

// without radian conversion
0.523599

I would be glad if you could also help this one.
Thanks alot.
Mar 24 '07 #5
"asd" <no****@nospam.comwrote in message
news:pa****************************@nospam.com...
Thank you so much for all of your answers.

Now I am struggling with asin.

the test file has:
asin(.5);

// test output
30

// My output with radian conversion
0.00872676

// without radian conversion
0.523599

I would be glad if you could also help this one.
Thanks alot.
comments for asin in VC++ is:

The units of the returned elements are in radians.
The return value is a principal value between +pi/2 and -pi/2 that is
consistent with the sine value input.

No way you're going to get a value of 30 out of that unless you multiply it
by some factor. I don't know where they get 30 from.

Mar 24 '07 #6
asd
On Sat, 24 Mar 2007 15:31:09 -0700, Jim Langston wrote:
"asd" <no****@nospam.comwrote in message
news:pa****************************@nospam.com...
>Thank you so much for all of your answers.

Now I am struggling with asin.

the test file has:
asin(.5);

// test output
30

// My output with radian conversion
0.00872676

// without radian conversion
0.523599

I would be glad if you could also help this one.
Thanks alot.

comments for asin in VC++ is:

The units of the returned elements are in radians.
The return value is a principal value between +pi/2 and -pi/2 that is
consistent with the sine value input.

No way you're going to get a value of 30 out of that unless you multiply it
by some factor. I don't know where they get 30 from.

Thank you so much Jim, it worked.

Mar 25 '07 #7
Kai-Uwe Bux <jk********@gmx.netwrote:
You are confusing different ways of measuring angles. A half of a right
angle can be specified as 45 deg or as Pi/8 rad.
I think you mean Pi/4 rad.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Mar 26 '07 #8
Marcus Kwok wrote:
Kai-Uwe Bux <jk********@gmx.netwrote:
>You are confusing different ways of measuring angles. A half of a right
angle can be specified as 45 deg or as Pi/8 rad.

I think you mean Pi/4 rad.
Sort of: I think, I meant 2*Pi/8 :-)
Thanks

Kai-Uwe Bux
Mar 26 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1515
by: Sandra Setz | last post by:
Hello, I have made a view in SQL Server, that consists of a join with another view and a table. That other view In Access, I have linked the view as a linked table. When I view the result...
6
2717
by: Bern McCarty | last post by:
I'm trying to use the VS 2005 March Tech Preview and am trying to adjust some MC++ to the new C++/CLI syntax. I got a little hung up when I encountered the below error. Certainly my...
0
1014
by: Boo Khan Ming | last post by:
Hi, I got an AccessDataSourceControl (from Web Matrix), and there is one line result expected from .selectcommand="select sum(totalprice) from sales" table. So, the easiest way, how do I...
5
2375
by: Squeamizh | last post by:
The subject line probably isn't the best, but I don't know how else to describe my question. When I try to compile the code below, my compiler reports an error (error text is below code sample)....
1
1890
by: INeedADip | last post by:
What is the difference between: function setupGrid( param ){......} and setupGrid = function( param ){......} Are there any advantages to doing one over the other?
4
9099
by: kinaxx | last post by:
Hello, now I'm learning progamming language in university. but i have some question. in textbook. says there are four passing Mechanism 1) pass by value (inother words : call by value) 2)...
1
3992
by: Anup Gupta | last post by:
imsc_int32_t imsc_wsprintf( OUT imsc_wchar_t *s, IN imsc_wchar_t *format, ...) { va_list ap; imsc_int32_t dNumBytes; va_start(ap, format); dNumBytes = swprintf(s,format, ap);...
1
2922
by: Angus | last post by:
Why moving a function from protected to public area in class causes error C2556 - overloaded function differs only by return type I have a protected function called GetState like this: enum...
1
6555
by: garimellasrinivasu | last post by:
Hi All, i am using VS2008 and trying to port my previous application which is working fine in VS2003. I am facing the following problem in this version(VS2008).. Please guide me how to solve this...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
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...
1
5079
isladogs
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...
0
4743
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
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 ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.