Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - PocketC help

PocketC help

Postby fishTail on Sat Oct 12, 2002 7:07 pm

Help! I am a PocketC beginner and have written some simple programs already. However, I have tried writing programs incorporating Trig functions and do not get the expected result from them.

i.e Tan 30 degrees=-6.405
when I am expecting 0.5773502 or similar.

Any help for what I am doing wrong would be appreciated.
fishTail
 
Posts: 3
Joined: Sat Oct 12, 2002 6:52 pm
Location: United Kingdom

Postby samps on Sat Oct 12, 2002 9:01 pm

You're getting the wrong values (actually you're getting the RIGHT answers to the wrong questions) because PocketC is using RADIANS, not DEGREES

To get the expected TAN value you'll have to convert from degrees to radians before calling tan()...

Your angle, 30 degrees, is 30/360th of a circle, and a circle is 2*pi radians



//tans

float angle;
main()

{
angle=30.0/360*6.28;
alert(tan(angle));
}


you'll get used to it

Samps
Ubuntu user #82
samps
 
Posts: 143
Joined: Tue Feb 20, 2001 12:33 am
Location: Australia

Postby wolfgang on Sun Oct 13, 2002 5:32 am

A little more exact (I don't know how many digits you need), but for PocketC float calculations having about 7 significant digits, better use 3.1415927 for PI instead of 3.14 as used in the previous post.

Wolfgang

Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby fishTail on Sun Oct 13, 2002 11:39 am

Many thanks for answer.:D I wish textbooks had expanded a little more on topic. I'd been wrestling with that one for a while and couldn't find any examples/ code anywhere with trig. in them.
Straight forward once you know, but for a beginner.....
fishTail
 
Posts: 3
Joined: Sat Oct 12, 2002 6:52 pm
Location: United Kingdom

Postby soinsg on Sun Oct 13, 2002 2:42 pm

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by samps</i>
<br />angle=30.0/360*6.28;
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

You code probably make this faster my combining the 360 and the 6.28 as they are both constants (won't change).

<pre id="code"><font face="courier" size="2" id="code">
angle=30.0/1130.973;
</font id="code"></pre id="code">
soinsg
 
Posts: 198
Joined: Thu May 17, 2001 4:26 pm

Postby fishTail on Mon Oct 14, 2002 7:44 pm

Hi, thanks for input but is that not 30.0/57.2957877

i.e 57.295 etc. not 1130.973 :?:

......but hey, I get the constant idea.
fishTail
 
Posts: 3
Joined: Sat Oct 12, 2002 6:52 pm
Location: United Kingdom

Postby soinsg on Tue Oct 15, 2002 6:50 pm

57.. is one radian?
and 6.28 is 2 pi radians, which is 360 degrees, wait, I'm confusing myself!

Anyway I figure that you got: 30.0/360*6.28 (from samps)
And following BIDMAS the multiplication and division are on the same level, so you can do 360 * 6.28 = 1130.. then stick that in the original to get 30.0/1130.97
soinsg
 
Posts: 198
Joined: Thu May 17, 2001 4:26 pm


Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 2 guests

cron