??? 03/13/08 02:01 Read: times |
#152201 - Not right Responding to: ???'s previous message |
(float)SR = ((S1 + S2)/0x02); // wrong
SR = (float)((S1 + S2)/0x02); // do math then convert to a float SR = (((float)S1 + (float)S2)/0x02); // do math as float SR should be a 16 or 32 bit number. On an 8052 float is big and slow. Plus you get float rounding errors as a bonus. (ie 1 / 3 * 3 may not equal 1). If you need speed 16 variables may be the answer. Or you can add straight out of the A2D. S1 to 16 can be 8 bit but to get 16 bit addition you must cast unsigned int SR; unsigned int S1,S2; SR = (unsigned int)S1 + S2; someone will correct me if I am wrong, but I think you only need to cast one of them |
Topic | Author | Date |
Math not functioning with proper headers? | 01/01/70 00:00 | |
horrible method | 01/01/70 00:00 | |
Lots of issues | 01/01/70 00:00 | |
Code Op at level 8 | 01/01/70 00:00 | |
Try multiple steps | 01/01/70 00:00 | |
ah hah moment arrived......omg | 01/01/70 00:00 | |
01/01/70 00:00 | ||
Here is the block which now works 100% | 01/01/70 00:00 | |
Operation question in C | 01/01/70 00:00 | |
Because | 01/01/70 00:00 | |
Simplify | 01/01/70 00:00 | |
what's the point ? | 01/01/70 00:00 | |
What's the point | 01/01/70 00:00 | |
simpler, but | 01/01/70 00:00 | |
Not right | 01/01/70 00:00 | |
use shift right instead of divide | 01/01/70 00:00 | |
If you're lucky... | 01/01/70 00:00 | |
Use a rount trip buffer | 01/01/70 00:00 | |
Bad names | 01/01/70 00:00 | |
System use names ???? | 01/01/70 00:00 | |
Common naming convention ? | 01/01/70 00:00 | |
ISO/IEC 9899:1990... | 01/01/70 00:00 | |
Comments | 01/01/70 00:00 | |
same effect as a "circular array" | 01/01/70 00:00 | |
think I like this the best | 01/01/70 00:00 | |
Use a loop with deglitching and averaging![]() | 01/01/70 00:00 |