Use Sensor.getResolution() to calculate the number of decimal digits to be displayed.