How do I print a number in simplest form?
The numbers I have are specifed to two decimal places, but I do
not want trailing 0's or decimal point. (I allow input of two decimal
places, but the precision does not need to be printed.)
transform(5.30) gives "5.30", and I want "5.3".
transform(5.00) gives "5.00", and I want "5".
I also do not want any leading spaces. I can ltrim() for that
though.
I get a surprising result with overprecise constants:
n=5.3000
? transform(n) && outputs "5.3000"
n=5.30
? transform(n) && outputs "5.30"
n=5.00
? transform(n) && outputs "5"
I expected "5.00" from the last.
What is the easiest way to deal with this?
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.