Add support for preserving scientific notation for floats#225
Conversation
Introduced mechanisms to handle and preserve scientific notation formats across parsing, transformation, and reconstruction processes. Added tests for various float representations to ensure functionality, including edge cases with scientific notation and negative decimals.
|
Hi! Thank you for looking into the issue and taking time to prepare a PR. {
"floats": {
"inline_scientific": [
"${-5.1e2}",
"${-3.7e1}"
],
"object_scientific": [
{
"__sci_float__": true,
"value": -510.0,
"format": "-5.1e2"
},
{
"__sci_float__": true,
"value": -37.0,
"format": "-3.7e1"
}
]
}
}and try to do the below in terraform: output "o1" {
value = sum(jsondecode(templatefile("./floats.json", {}))["floats"]["inline_scientific"])
}
output "o2" {
value = sum(jsondecode(templatefile("./floats.json", {}))["floats"]["object_scientific"])
}
|
Problem
With the hcl2.reverse_transform isn't capable of handling floats.
Implementation
Added case within
HCLReverseTransformer._transform_value_to_expr_termto properly generate theexpr_termfor floats.Added tests for various float representations to ensure functionality, including edge cases with scientific notation and negative decimals.
Introduced mechanisms to handle and preserve scientific notation formats across parsing, transformation, and reconstruction processes.