From eabee5bd241e026c9e954c110b406732e99b32ea Mon Sep 17 00:00:00 2001 From: nineonine <mail4chemik@gmail.com> Date: Tue, 1 Mar 2022 23:48:01 -0800 Subject: [PATCH] smallpt: truncate result Current test does some floating-point manipulations which can be non-deterministic due to different platforms/architectures. This change truncates the result to avoid potential stdout mismatch. --- real/smallpt/smallpt.hs | 3 +-- real/smallpt/smallpt.stdout | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/real/smallpt/smallpt.hs b/real/smallpt/smallpt.hs index 8201595e..9c910752 100644 --- a/real/smallpt/smallpt.hs +++ b/real/smallpt/smallpt.hs @@ -222,5 +222,4 @@ main = do vec <- smallpt w h samples if mode == "img" then writeImage stdout (w, h) vec - else hPutStr stdout (hashImage vec) - + else hPutStr stdout (printf "%.6f" (read (hashImage vec) :: Double)) diff --git a/real/smallpt/smallpt.stdout b/real/smallpt/smallpt.stdout index 57ea5394..a877e7ff 100644 --- a/real/smallpt/smallpt.stdout +++ b/real/smallpt/smallpt.stdout @@ -1 +1 @@ -42517.5950581666 \ No newline at end of file +42517.595058 -- GitLab