This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Whats happening here ??

Hallo everybody,

got myself another problem.... not exactly a problem... i think
The thing is i would like to know whats happening in this output:

printf("AIN[%d][%d] = %u.%.3u V\n",m,n,(int)(AD_ARRAY[m][n]/V_SCALE),(int)(AD_ARRAY[m][n]%V_SCALE)*R_SCALE);

The preprocessor declarations are :

ine V_REF 5
#define V_SCALE (0xFF/V_REF)
#define R_SCALE (99/V_REF)

I am using a 80C535 µC and the AD_ARRAY[m][n] saves the actual ADC value of the sample and im using µVision2

Thanks for the help
Andy

Parents
  • Normally, you would emit the measurement as a floating point value. However, embedded chips normally don't like floating point numbers.

    So, it is first calculating and emitting the integer part - the digits before the decimal point. Then it is removing the integer part by using the modulo operator % and multiplying the remaining value (which represents the fractional part) and emits that as a second number.

Reply
  • Normally, you would emit the measurement as a floating point value. However, embedded chips normally don't like floating point numbers.

    So, it is first calculating and emitting the integer part - the digits before the decimal point. Then it is removing the integer part by using the modulo operator % and multiplying the remaining value (which represents the fractional part) and emits that as a second number.

Children
No data