When I use toString() for JScience Amount objects I get results like this:
(7.5 ± 4.4E-16) mph
This isn't awful, but I'd really like it to output something like:
7.5 miles per hour
Is there an easy way to do this?
edit: Just to clarify, I'm hoping for a solution that will work for any Amount with any type of Units (or at least all of the pre-defined ones), not just "mph".
Although it discards the errors and units, you can do something like this:
Console:
Addendum: I'm hoping for a solution that works for any amount with any units.
You'll still have to provide your own label to replace the default
UnitFormat
; the label characters are limited byisValidIdentifier()
. You can also substitute your ownAmountFormat
, as suggested by @Roger Lindsjö. This example prints an arbitrary number of significant digits of the estimated value and a valid variation of your label. See alsoTypeFormat
.Console: