Go to Post This brings back childhood memories of playing with erector sets... Wait. I still do. :D - Whippet [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2005, 20:39
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Weird tangus value (i. e. tan(75)=27,XXX)

I have been working on using trigonometric functions in our code (In order to calculate distance from robot to vision tetra) and while it is able to calculate the value of tan(45) as 1, any other tan(x) value would be a decimal value, therefore i changed the variable that i had stored the value in to a float type, and told it to calculate some other tan(x) values (Just to make sure that the functions works). I have been getting as an answer some huge 5 digit numbers such as the one in the subject (Where 'XXX' is some 3 random numbers). Most of these numbers are somewhere near various powers of 2, such as 2^14, and 2^16. This has been happening with both Team 296 CORDIC Math library, and the math.h library that comes with the mcc18 compiler. Does anyone know what might be causing this?

Thank you for the help,

Dan
  #2   Spotlight this post!  
Unread 04-02-2005, 20:53
schenkin schenkin is offline
Registered User
#0486
 
Join Date: Jan 2005
Location: Strath Haven High School
Posts: 17
schenkin is on a distinguished road
Re: Weird tangus value (i. e. tan(75)=27,XXX)

I have had the exact same problem before. I am pretty sure the problem occurs when it tries to change the float to an int. If you aren't doing that, make sure you are declaring the variable as an float when you printf() it. That fixed our problem anyway
  #3   Spotlight this post!  
Unread 04-02-2005, 21:11
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Weird tangus value (i. e. tan(75)=27,XXX)

Thanks for the reply, schenkin. Your reply prompted me to google the % specifiers used in ANSI C, and i figured out that i was using %d - signed integer, instead of %f - signed decimal.

Thanks for your reply,

Dan
Team 375
  #4   Spotlight this post!  
Unread 16-02-2005, 01:23
the_undefined's Avatar
the_undefined the_undefined is offline
German FES
AKA: Felix Geisendörfer
#1648 (Gearbox Gangstas)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Germany
Posts: 77
the_undefined has a spectacular aura aboutthe_undefined has a spectacular aura about
Re: Weird tangus value (i. e. tan(75)=27,XXX)

Quote:
Originally Posted by dhoizner
Thanks for the reply, schenkin. Your reply prompted me to google the % specifiers used in ANSI C, and i figured out that i was using %d - signed integer, instead of %f - signed decimal.

Thanks for your reply,

Dan
Team 375
Hmm but I'm afraid %f is not an option with our version of the printf function ... : (
  #5   Spotlight this post!  
Unread 16-02-2005, 01:24
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Weird tangus value (i. e. tan(75)=27,XXX)

Quote:
Originally Posted by the_undefined
Hmm but I'm afraid %f is not an option with our version of the printf function ... : (
That is correct. The printf functions provided by FIRST and Microchip do not support floating point variables.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Al? George A. Chit-Chat 6 13-07-2004 07:22
Really weird... Alaina Chit-Chat 7 17-08-2003 21:23
Weird Al MattK Chit-Chat 7 10-11-2002 00:33
the weird feeling.. archiver 2000 3 23-06-2002 23:08
Is it weird to see an atwood motor floating in mid air? mnkysp6353 Chit-Chat 6 19-02-2002 21:38


All times are GMT -5. The time now is 19:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi