General area when it fits no where else

Moderator: Mmiscool

User avatar
By heckler
#65875 Hey Group,

I am reading a ds18b20 temperature sensor.
The value returned is generally a number with 4 digits after the decimal point.
ie. 86.0625
I would like to round it to just 1 digit after the decimal but I would like to round properly such that 86.0625 will display as 86.1

I would greatly appreciate any guidance on how to do this in espBASIC

thanks in advance
dwight
User avatar
By taikapanu
#65881 Hi,

Not familiar with BASIC but here is what I found from documentation:
https://docs.google.com/document/d/1EiY ... YyJon8/pub
round(x):

Return the integral value nearest to x rounding halfway cases away from zero, regardless of the current rounding direction.


So maybe first multiply by 10 to move desimal --> use round function --> divide by 10 to get that one desimal back.

No idea if it works but something to try :)