Skip to content

Commit

Permalink
Add debug log only when value has exact accuracy in both float32 an…
Browse files Browse the repository at this point in the history
…d `float64`
  • Loading branch information
SBGoods committed Jul 1, 2024
1 parent 51b07aa commit 9038a0f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions types/basetypes/float32_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ func (t Float32Type) ValueFromTerraform(ctx context.Context, in tftypes.Value) (
}

f, accuracy := bigF.Float32()
logging.FrameworkDebug(ctx, fmt.Sprintf("Float32Type ValueFromTerraform Float32 value %f, accuracy %d", f, accuracy))
f64, f64accuracy := bigF.Float64()
logging.FrameworkDebug(ctx, fmt.Sprintf("Float32Type ValueFromTerraform Float64 value %f, accuracy %d", f64, f64accuracy))

if accuracy == big.Exact && f64accuracy == big.Exact {
logging.FrameworkDebug(ctx, fmt.Sprintf("Float32Type ValueFromTerraform: big.Float value has distinct float32 and float64 representations "+
"(float32 value: %f, float64 value: %f)", f, f64))
}

// Underflow
// Reference: https://pkg.go.dev/math/big#Float.Float32
Expand Down

0 comments on commit 9038a0f

Please sign in to comment.