diff options
| author | Cliff Click <cliffc@acm.org> | 2025-03-15 16:05:04 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-03-15 16:05:04 -0700 |
| commit | 5097e9f08dacb25e4c4aca20b48aa7d523067628 (patch) | |
| tree | fe67f3f1ed282394668e06ae12917879ad3ff56b /chapter21/src/test/java | |
| parent | fe27a3326becaf1a59286fa03d9aaa22504ec4ee (diff) | |
| download | Simple-5097e9f08dacb25e4c4aca20b48aa7d523067628.tar.gz Simple-5097e9f08dacb25e4c4aca20b48aa7d523067628.zip | |
Encoding fixes
Diffstat (limited to 'chapter21/src/test/java')
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java | 20 |
1 files changed, 20 insertions, 0 deletions
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); + } } |
