Hi. For integers, values are always whole numbers (integral) so you will never get a 0.09 value. Typically the PIC will always round these values down.
If you are on Windows 7 then the calculator provided has a 'Programmer' mode. This always does integer maths so you can find what your calculations would be using integers.
If you change your formula to be:
Ustrkorr = ( adc_level_current / 100 )
Then this is the value multiplied by 100 - in your case 100 to 109. You can then use a bit of maths to get the integer and remainder parts:
integer = Ustrkorr / 100
decimal = Ustrkorr % 100
There are more efficient ways than this if you need this to run quickly.
If all you need to do with Ustrkorr is this temporary value then:
Code: Select all
Ustrkorr = ( adc_level_current / 600 )
Ukorred = (U_bor_Step_One * Ustrkorr) / 100 + U_bor_Step_One
Should get you the result you require a bit more accurately. I suspect though that unless U_bor_Step_One is quite large this will also truncate to an integer in a way you wont like.
You may need to have a look at your program and see whether it is possible to keep the values as large as possible for as long as possible - in general you would only do the divide when you need to display the values, to maintain accuracy.
Jonny