|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
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
|
|||
|
|||
|
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
|
|||||
|
|||||
|
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
|
||||
|
||||
|
Re: Weird tangus value (i. e. tan(75)=27,XXX)
Quote:
|
|
#5
|
||||
|
||||
|
Re: Weird tangus value (i. e. tan(75)=27,XXX)
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |