-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable interpolation doesn't work for floats #7887
Comments
@joshuaspence I am curious, what is your use case? |
Hi @joshuaspence - thanks for the report. I seem to recall this being an issue for a little bit now, but I can't find the duplicate right now. I'll link back if it comes up. You should be able to work around this bug by forcing float math by adding |
The use case is that I'm building a Grafana dashboard and I want to set a threshold on a graph to be just-a-little-bit-smaller-than an integer value. I was trying to do this as |
Thanks for the workaround @phinze. |
@joshuaspence ah, got it. Thank you! |
Turns out we need to rethink this fix - reopening! |
So I have a use case here surrounding cidr math.
The above shows that if the numerator is a float, then floating point math is initialized. I would presume that it should always be floating point math, and we could use the My use case is computing subnet space within a given cidr. For example we have 5 total subnets, I need to compute the largest subnet within a given subnet (for example, 10.20.30.0/24). Needing 5 subnets in a /24 subnet means the largest subnet size I can use is /27 -
However; Since I am breaking up that 5 into "2 + 3" and instead of forcing the user to input "2.0 + 3.0" I'm not getting floating point math. I think it is reasonable to return a float in ALL situations of division |
Hey @mengesb there is a new issue that was just opened today actually and we've committed to this behavior. I'm going to close this but would you mind watching that issue (should be easy to find with label:bug label:core since it was today). |
Seems that math in general has some issues:
|
Reference: #10778 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I'm testing Terraform at HEAD and it seems that variable interpolation inside a string assumes that arguments are integers. For example, the following snippet fails:
The error message is:
It looks like
x
andy
are being parsed as integers rather than floats because${0.001 + 0.002}
works fine.The text was updated successfully, but these errors were encountered: