Base the number of decimal digits on actual sensor resolution.

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