I shifted the 0.0012219 decimal place 7 steps to the left right to make it a whole number. For instance, 1023 * 12219 = 12500037 would be your maximum value in integers. Float can store very small to very large numbers, but only to a few useful digits of precision.ĭouble (64 bit float) is better, or do what I usually do and use integers by scaling all the values by powers of ten. Note that 32 bit floating point is quite limited in resolution, due to having to store the exponent too. So, if you pass a float to printf but have told printf to expect an integer (with w), printf will just display the 32 bits as if it is a simple integer and the result will be strange. Floats are stored as a sign bit, an exponent, and a mantissa within the 32 bits. It's not to do with w specifying unsigned, it is to do with it specifying integer.Ī floating point number is stored completely differently to an integer. Set_adc_channel(7) // Sets a/d channel to number 7Īdcvalue = read_adc() // gets value of 0-1023 Setup_adc(ADC_CLOCK_INTERNAL) // Built-in A/D setup function Setup_adc_ports(sAN4|sAN5|sAN6|sAN7|VSS_VDD) The software i am using is CCS PIC-C 5.083 The code i am using is, i have taken out the code that was commented out Hi and thandks, i will have a look at it later.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |