* Returns the number of decimal places a number has. * * @param num The number to check.
(num: number)
| 27 | * @param num The number to check. |
| 28 | */ |
| 29 | function precision(num: number): number { |
| 30 | const decimalPart = num.toString().split('.', 2)[1]; |
| 31 | if (decimalPart === undefined) { |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | return decimalPart.length; |
| 36 | } |
| 37 | |
| 38 | // https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html |
| 39 | const EQUATORIAL_EARTH_RADIUS = 6378.137; |