I would like to format some double values to a specific number of digits ignoring starting zeros.
Example, lets say format to 6 digits:
131.468627436358 -> 131.469
3.16227766016838 -> 3.16228
0.66018099039325 -> 0.660181
0.02236067977499 -> 0.0223607
BigDecimal allows handling of significant figures correctly. This:
produces:
Obviously, though, passing your floating points through an arbitrary precision object representation isn’t ideal.