From f07306d82f2eec12c3a4084ea07945d6fc27bbff Mon Sep 17 00:00:00 2001 From: Baptiste Date: Mon, 1 Apr 2024 15:04:41 +0200 Subject: [PATCH 1/2] Adds a COBOL example --- _posts/2024-04-01-cobol.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _posts/2024-04-01-cobol.md diff --git a/_posts/2024-04-01-cobol.md b/_posts/2024-04-01-cobol.md new file mode 100644 index 0000000..d4b9fad --- /dev/null +++ b/_posts/2024-04-01-cobol.md @@ -0,0 +1,23 @@ +--- +title: COBOL +code: |- + IDENTIFICATION DIVISION. + PROGRAM-ID. HFPMATH. + DATA DIVISION. + WORKING-STORAGE SECTION. + 77 X-32 USAGE COMP-1. + 77 X-64 USAGE COMP-2. + PROCEDURE DIVISION. + COMPUTE X-32 = 0.1 + 0.2. + DISPLAY X-32. + COMPUTE X-64 = 0.1 + 0.2. + DISPLAY X-64. + MOVE 0.1 TO X-64. + DISPLAY X-64. +result: |- + 0.30000001 + 0.3 + 0.09999999999999999" +--- + +COBOL encodes floating-point numbers using the HFP format instead of IEEE754, leading to different but analogous computation innacuracies. From 1925b915cc68094fbeade40b353072602d7261e2 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Mon, 1 Apr 2024 15:12:36 +0200 Subject: [PATCH 2/2] adds explanation about the HFP format + removes an outstanding quote --- _posts/2024-04-01-cobol.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_posts/2024-04-01-cobol.md b/_posts/2024-04-01-cobol.md index d4b9fad..023eb7f 100644 --- a/_posts/2024-04-01-cobol.md +++ b/_posts/2024-04-01-cobol.md @@ -17,7 +17,9 @@ code: |- result: |- 0.30000001 0.3 - 0.09999999999999999" + 0.09999999999999999 --- -COBOL encodes floating-point numbers using the HFP format instead of IEEE754, leading to different but analogous computation innacuracies. +COBOL encodes floating-point numbers using the [HFP][1] format instead of IEEE754, leading to different but analogous computation inaccuracies. + +[1]: https://en.wikipedia.org/wiki/IBM_hexadecimal_floating-point