From 5097e9f08dacb25e4c4aca20b48aa7d523067628 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 15 Mar 2025 16:05:04 -0700 Subject: Encoding fixes --- .../java/com/seaofnodes/simple/Chapter21Test.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'chapter21/src/test/java/com') diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java index 770c7165..e2a79b8f 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -42,4 +42,24 @@ public class Chapter21Test { testCPU(src,"arm" , "SystemV",0,"return (or,arg,2);"); } + @Test + public void testNewtonFloat() { + String src = +""" +// Newtons approximation to the square root +val sqrt = { flt x -> + flt guess = x; + while( 1 ) { + flt next = (x/guess + guess)/2; + if( next == guess ) return guess; + guess = next; + } +}; +flt farg = arg; +return sqrt(farg) + sqrt(farg+2.0); +"""; + testCPU(src,"x86_64_v2", "SystemV",25,null); + testCPU(src,"riscv" , "SystemV",17,null); + testCPU(src,"arm" , "SystemV",18,null); + } } -- cgit v1.2.3