From f95f56831997bf37ee5e13ed8cfde2fb625d84f6 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 12 Feb 2026 02:29:10 +0100 Subject: [PATCH] fix mflpt5 overflow error message --- codeCore/src/prog8/code/target/Mflpt5.kt | 4 ++-- compiler/test/TestNumbers.kt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codeCore/src/prog8/code/target/Mflpt5.kt b/codeCore/src/prog8/code/target/Mflpt5.kt index abb1e4f0d..ade58279b 100644 --- a/codeCore/src/prog8/code/target/Mflpt5.kt +++ b/codeCore/src/prog8/code/target/Mflpt5.kt @@ -19,7 +19,7 @@ data class Mflpt5(val b0: UByte, val b1: UByte, val b2: UByte, val b3: UByte, va val flt = num.toDouble() if (flt !in FLOAT_MAX_NEGATIVE..FLOAT_MAX_POSITIVE) - throw InternalCompilerException("floating point number out of 5-byte mflpt range: $this") + throw InternalCompilerException("floating point number out of 5-byte mflpt range: $flt") if (flt == 0.0) return zero @@ -40,7 +40,7 @@ data class Mflpt5(val b0: UByte, val b1: UByte, val b2: UByte, val b3: UByte, va return when { exponent < 0 -> zero // underflow, use zero instead - exponent > 255 -> throw InternalCompilerException("floating point overflow: $this") + exponent > 255 -> throw InternalCompilerException("floating point overflow: $flt") exponent == 0 -> zero else -> { val mantLong = mantissa.toLong() diff --git a/compiler/test/TestNumbers.kt b/compiler/test/TestNumbers.kt index 4c0005097..71245e338 100644 --- a/compiler/test/TestNumbers.kt +++ b/compiler/test/TestNumbers.kt @@ -85,10 +85,10 @@ class TestNumbers: FunSpec({ Mflpt5.fromNumber(1.7e-39) shouldBe Mflpt5(0x00u, 0x00u, 0x00u, 0x00u, 0x00u) Mflpt5.fromNumber(-1.7e-38) shouldBe Mflpt5(0x03u, 0xb9u, 0x1du, 0x15u, 0x63u) Mflpt5.fromNumber(-1.7e-39) shouldBe Mflpt5(0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - shouldThrow { Mflpt5.fromNumber(1.7014118346e+38) } - shouldThrow { Mflpt5.fromNumber(-1.7014118346e+38) } - shouldThrow { Mflpt5.fromNumber(1.7014118347e+38) } - shouldThrow { Mflpt5.fromNumber(-1.7014118347e+38) } + shouldThrow { Mflpt5.fromNumber(1.7014118346e+38) }.message shouldContain "mflpt range: 1.7014118346E38" + shouldThrow { Mflpt5.fromNumber(-1.7014118346e+38) }.message shouldContain "mflpt range: -1.7014118346E38" + shouldThrow { Mflpt5.fromNumber(1.7014118347e+38) }.message shouldContain "mflpt range: 1.7014118347E38" + shouldThrow { Mflpt5.fromNumber(-1.7014118347e+38) }.message shouldContain "mflpt range: -1.7014118347E38" } test("testMflpt5ToFloat") {