Back to project page Sensoria.
The source code is released under:
MIT License
If you think the Android project Sensoria listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.grocs.sensors.common; /*w w w .j a va2 s . co m*/ /** * FloatConvertor class is taking care of rounding floats (based on given precision) */ class FloatConvertor { private final int multiplier; /** * Creates FloatConvertor with a given precision * @param precision, amount of digits behind the comma */ FloatConvertor(final int precision) { multiplier = (int) Math.pow(10, precision); } /** * Creates FloatConvertor with a 0 precision */ FloatConvertor() { this(0); } /** * Convert to a given precision * @param f float to convert * @return converted float */ float doConvert(float f) { return (float) Math.round(f * multiplier) / multiplier; } }