Wrong values with COSINE!
Hello,
i am working on a very serious project and i chose to use PicBasic Pro.
but i just encountered a serious problem:
in a certain part of my program i got a certain value "alpha". I needed to get cosine alpha.
but the problem is that:
"COS returns the 8-bit cosine of a value. The result is in two’s complement
form (i.e. -127 to 127). It uses a quarter-wave lookup table to find the
result. Cosine starts with a value in binary radians, 0 to 255, as opposed
to the usual 0 to 359 degrees."
but i need the usual 0 to 359 degrees!! and this is so essential in my program!
Now i am getting: cos 0 = 127 ! i just need to get back the normal values example: cos 0 = 1, cos 90 = 0, cos 70 = 0.342
Please any help??
It's so URGENT... write a code if possible and i'll be more than grateful...
it's not about integers...
I wasn't talking about integers... i noticed that you wre only concentrating on me sending many posts.. why not concentrating about the contents of posts?
the cosine and sine functions are not giving the basic answers...they are giving results in twos's complement!
for example, instead of giving a "1" for "cosine 0", it is giving 127!!
i need to go to the normal numbering system... anyone has a hint?
Idiot Inside or Outside ????
Quote:
Originally Posted by Luciano
Hi Luciano,
You like living dangerously ...
Our Genius told you it was VERY IMPORTANT and VERY URGENT... a question of life ; might be yours !!!
May be we've forgotten to tell him 8th Bit is sign and 7 others the absolute value in 1/127 steps.
Gee, I run and upload my Marlin 444 ... one never knows.
Good night, Mr Genius ...
Alain
Hey people.... thanks for your replies!:)
Some of you are good ones and others are.... really bad! especially the one of lights and bulbs! haha.
Dear Sirs,
my question was simple and clear. You do not have to worry about what i am doing and why i did not use a table! you really have smart ideas there! but i just needed to see if there is one single HEAD of you able to solve this matter...
i have 3 possibilities other than using TABLES.. but i still only have to solve this matter which is:
i need to use the provided "cosine" question in the PicBasic Pro tutorial in order to get the usual answers... like cos 0 = 1 and cos 90 = 0 etc etc
so just in case someone has a method, please say it and give the method otherwise, if it is only for dummie answers and stupidities, i have enough of IMPORTANT things to deal with and not obliged deal with bulbs and lights or anything else....
By the way Mr Bulb, as long as I DUNNO WITH WHOM I AM TALKING.... why don't you show me what do you have INSIDE your brain? and not just what you USED to do in the past?
maybe still dealing with bulbs till now?..........
Come on people! the world has changed! lol
You know what i like about forums?
Quote:
Originally Posted by BigWumpus
And out of this silly task you are able to make such a lot of dust ?
P=V*I 16 Bit
X=COS(Alpha*255/360) 8 Bit 2-komplement
Minus=X.7
P=P*(X and %01111111) 32 Bit !!!
P=Div32 127
It's quick-n-dirty, maybe there is an error inside....
Just USE YOUR BRAIN, not your mouth !
Hello Mel,
Yes, I ruin you prices and your time....
but I inserted 1 mistake, so will not work right. But some postings ago, there was the right hint. Maybe we could train his brain....
--------------------------------------------------------------------
It's just that you like to show up... i wonder if you succeeded because for me you were just acting like a clown... trying to be nice to mel just by making fun of me.
i wonder what you get from all this - stupid... and moreover, you wanna train my brain? lol and you submit and error on purpose???!
i came here because i didn't know how to do it so do you really find it worthy to take all your advantages and try to make fun of me?? or just to appear the intelligent?? you are idiot! keep your knowledge for yourself.
In case someone else has an idea about my question i'll be grateful.
By the way Mel,
Did you made this forum just to make fun of people with your friends?
thanks a lot for your kindness.
Sorry i forgot one thing..
Thanks Melanie a lot.
Your code is great and it worked perfectly.
Luciano,
Also a big thanks because that article is extremely important.