Reputation: 769
I'm trying to convert decimal numbers to percentages using Terraform. It works for some decimals, but not others.
For example:
$ terraform console
> 0.2 * 100
20
> 0.01 * 100
0.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
> 0.005 * 100
0.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999996
Calling ceil
or floor
won't be appropriate in this case.
I've replicated this behaviour in Terraform 1.1.4 and 1.2.3.
Any ideas on how to resolve this?
Upvotes: 1
Views: 755