diff options
| author | eunhhu <[email protected]> | 2026-10-19 01:53:40 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-19 01:53:40 +0100 |
| commit | defb2cf06a9b5db9429ca368d8c2af127a5c9c3d (patch) | |
| tree | b13c94eb334ce2a5055854791900f8702ba9fc3b /core/test-module.c | |
| parent | 809a83a5764ec0f0c84b96c43a20cfb906eee031 (diff) | |
| download | pure-defb2cf06a9b5db9429ca368d8c2af127a5c9c3d.tar.gz pure-defb2cf06a9b5db9429ca368d8c2af127a5c9c3d.zip | |
027's 5c: money as i64 minor units shown by .Nd: NUM_TEXT's decimal form takes digits (bits 20-24 as FIXED's), an integer's last N digits written after a point (1234 at two is 12.34, -5 -0.05, 0 0.00; width and zeros after the sign), verification allowing digits on FIXED and DECIMAL alone; unit test: ten rows of formats_and_held (-2^63 at two, 25 digits, a number's whole 1234, its 12.5 a limit); TPC-C's money i64 cents and its rates ten-thousandths (tables, messages, load, the transactions), SQLite's INTEGER columns and int64 bindings alike, the comparison now exact (no 1e-9 tolerance): after 20,000 transactions every row of every table the same (grouped SQLite too) and 3.3.2 holding on both; counts: b45 against b44 BFS without batches +0.09%, the rest within 0.001%; the bank's queries (s44 and s45 in turns, six each) in_credit -0.59%, per_branch -0.34%, ranks -0.20%, the rest within 0.01%, the seven answers the same bytes; 008 (NUM_TEXT's digits, a message row's i64 cells), 027 and 092
Diffstat (limited to 'core/test-module.c')
| -rw-r--r-- | core/test-module.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/test-module.c b/core/test-module.c index 36722d2..f89e198 100644 --- a/core/test-module.c +++ b/core/test-module.c @@ -6166,7 +6166,8 @@ static void bits_and_bytes(void) { /* ---- Formats, slices and values held by name (docs/design/027, stage 2a) -- * NUM_TEXT writes a number, a bool or an i64 in a width, with zeros or - * spaces, in a base or with fixed digits; an integer's form fails as limit + * spaces, in a base or with fixed digits, or an integer in minor units + * (money's: 1234 at two digits is 12.34); an integer's form fails as limit * on a number that is not whole. BYTES_SLICE takes whole positions inside * the value; BYTE makes one byte. BYTES_LOAD and BYTES_STORE keep bytes * and texts by name for the event (a text's slots hold text alone): set, @@ -6194,6 +6195,17 @@ static void formats_and_held(void) { {0, 42, FMT(0, 0, 0, PURE_FORMAT_HEX, 0), PURE_FAULT_NONE, "2a"}, {0, 2.5, FMT(0, 0, 0, PURE_FORMAT_HEX, 0), PURE_FAULT_LIMIT, ""}, {0, 1, FMT(1, 6, 0, PURE_FORMAT_PLAIN, 0), PURE_FAULT_NONE, " true"}, + /* Money's form (027's stage 5): an integer in minor units, its last digits after a point. */ + {1, 1234, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "12.34"}, + {1, -5, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "-0.05"}, + {1, 0, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "0.00"}, + {1, -5, FMT(2, 7, 1, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "-000.05"}, + {1, 100, FMT(2, 6, 0, PURE_FORMAT_DECIMAL, 2), PURE_FAULT_NONE, " 10.0"}, + {1, 7, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 1), PURE_FAULT_NONE, "7"}, + {1, 5, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 26), PURE_FAULT_NONE, "0.0000000000000000000000005"}, + {1, -0x1p63, FMT(2, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "-92233720368547758.08"}, + {0, 1234, FMT(0, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_NONE, "12.34"}, + {0, 12.5, FMT(0, 0, 0, PURE_FORMAT_DECIMAL, 3), PURE_FAULT_LIMIT, ""}, }; for (size_t k = 0; k < LEN(shown); ++k) { O value = shown[k].i64 ? IC((int64_t)shown[k].value) : (O){C, shown[k].format & 3, shown[k].value}; |
