Roundings
Posted: Tue Nov 03, 2009 9:48 am
Hello,
Does anybody knows a good algoritm to simulate in Flowcode the C- function "floor" and "ceiling" to establish roundings on an integer.
What I mean is this: reading an ADC value of 834 ( representing a temperature of 83.4Β°C ), I want to round it to 830 ( giving a rounded temperature of 83Β°C). Simply deviding by 10 doesn't solve the problem because using this method a reading of eg 837 will result in the rounded value of 83Β°C instead of 84. And there is also the intermediate value of 835 which should result in 84Β°C.
I guess the functions floor and ceiling don't do the rounding correctly. Eg the floor function transforms 83.7 to 83 while the ceiling function transforms 83.2 to 84.
Probably the solution is simple, but I don't see it (yet).
Thanks for any input,
Eric
Does anybody knows a good algoritm to simulate in Flowcode the C- function "floor" and "ceiling" to establish roundings on an integer.
What I mean is this: reading an ADC value of 834 ( representing a temperature of 83.4Β°C ), I want to round it to 830 ( giving a rounded temperature of 83Β°C). Simply deviding by 10 doesn't solve the problem because using this method a reading of eg 837 will result in the rounded value of 83Β°C instead of 84. And there is also the intermediate value of 835 which should result in 84Β°C.
I guess the functions floor and ceiling don't do the rounding correctly. Eg the floor function transforms 83.7 to 83 while the ceiling function transforms 83.2 to 84.
Probably the solution is simple, but I don't see it (yet).
Thanks for any input,
Eric