From 9fe7c6f9697b5bbf3041261fdc60040e75cc674f Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 15 Nov 2026 16:11:39 -0800 Subject: Split off chapter 31 Ch 32 will be focused on compiler performance issues. --- .../seaofnodes/simple/FloatNegationNativeTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java (limited to 'chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java') diff --git a/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java b/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java new file mode 100644 index 00000000..dbbe353a --- /dev/null +++ b/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java @@ -0,0 +1,21 @@ +package com.seaofnodes.simple; + +import org.junit.Test; + +public class FloatNegationNativeTest extends TestC { + @Test public void negateRuntimeValues() throws Exception { + // Keep negation out of constant folding, including both signs of zero. + runSYS(""" + val neg_noInline={f64 x -> -x;}; + val main={ -> + if( neg_noInline(2.5)!=-2.5 || neg_noInline(-3.75)!=3.75 ) return 1; + if( 1.0/neg_noInline(0.0)!=-1e300*1e300 ) return 2; + if( 1.0/neg_noInline(-0.0)!=1e300*1e300 ) return 3; + if( neg_noInline(1e300*1e300)!=-1e300*1e300 ) return 4; + f64 nan=neg_noInline(1e300*1e300-1e300*1e300); + if( nan==nan ) return 5; + return 0; + }; + ""","floatNegation","",-1); + } +} -- cgit v1.2.3