Rounding

From Reboil

Rounding is the process of truncating digits from a number in order to communicate imprecision or to simplify information.

Stats

Review

Rounding is often necessary when processing raw measurements produced by digital devices that often produce floating point numbers with many more significant figures than what the deviceʼs accuracy should permit. Failure to round away digits may imply a measurement was more accurate than it was. For example, a GPS coordinate “47.62037758° N, 122.34923737° W” would imply a geolocation accuracy of approximately 50 millimeters; however, GPS coordinate are often only accurate to between 100 to 1000 centimeters; additionally, the object being indicated by the GPS coordinates is often larger than the accuracy provided by a GPS device. (e.g. the Seattle Space Needle, which is about 40 meters in diameter) Generally, coordinate accuracy should be about one tenth of the size of the subject.[1] In the case of the Space Needle, 4 decimal places would be sufficient. (i.e. 47.6203° N, 122.3492° W)

CLI commands

GNU Coreutils uses “bankerʼs rounding” (i.e. “round to even”). (See Useful CLI commands#printf)

$ printf "%.0f\n" "$myVar"

History

See also


External links

References

  1. Teslaton. (n.d.). “Geolocator”. Wikipedia.org. Accessed 2023-10-04.

Foonotes


Comments