Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/15/12 14:54
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#186695 - fixed point
Responding to: ???'s previous message
Jeremy Vella said:

float accdeg =((ADCacc - (616)) * 0.431);   /* 616 is my zero */
if (accdeg < (-20.0)) accdeg = (-20.0);     /*rejects wrong  values */
if (accdeg > (20.0)) accdeg = 20.0;
 

How about this then ?

uint32_t accdeg =((ADCacc - (616)) * 431);   /* 616 is my zero */
if (accdeg < (-20000)) accdeg = (-20000);    /*rejects wrong  values */
if (accdeg > (20000)) accdeg = 20000;
 

Instead of a factor 1000 you can also use 256 or 1024 or 65536 or whatever.

P.S. Please don't paste TAB's as every browser has a different idea of where the next column is.

List of 19 messages in thread
TopicAuthorDate
I'm having problems calculating negative float values            01/01/70 00:00      
   float values?            01/01/70 00:00      
      65536 no            01/01/70 00:00      
      negative float numbers            01/01/70 00:00      
         Two comparisons            01/01/70 00:00      
         Insufficient justification            01/01/70 00:00      
            re:insufficient justification            01/01/70 00:00      
   how are numbers transmitted?            01/01/70 00:00      
      serial Tx code            01/01/70 00:00      
         Data type?            01/01/70 00:00      
         Data type?            01/01/70 00:00      
            serialangle data type            01/01/70 00:00      
               Just a question of readability            01/01/70 00:00      
                  re: just a question of readability            01/01/70 00:00      
               why do you keep babbeling about 'float'            01/01/70 00:00      
                  float reason            01/01/70 00:00      
                     fixed point            01/01/70 00:00      
                        re:fixed point            01/01/70 00:00      
               typecast            01/01/70 00:00      

Back to Subject List