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") {