diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-12-13 12:58:18 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-01-04 15:53:36 +0100 |
commit | b605dbfcf04f310e08634b52507da7a4155bfce1 (patch) | |
tree | 04397dab9be96a5978e08366299671a8aa507267 /tests/custom/01_arithmetic/02_modulo | |
parent | 8907ce41a36f8d42097d884550fb3cfbba62e6c5 (diff) |
treewide: rework numeric value handling
- Parse integer literals as unsigned numeric values in order to be able
to represent the entire unsigned 64bit value range
- Stop parsing minus-prefixed integer literals as negative numbers but
treat them as separate minus operator followed by a positive integer
instead
- Only store unsigned numeric constants in bytecode
- Rework numeric comparison logic to be able to handle full 64bit
unsigned integers
- If possible, yield unsigned 64 bit results for additions
- Simplify numeric value conversion API
- Compile code with -fwrapv for defined signed overflow semantics
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/01_arithmetic/02_modulo')
-rw-r--r-- | tests/custom/01_arithmetic/02_modulo | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/custom/01_arithmetic/02_modulo b/tests/custom/01_arithmetic/02_modulo index 244d624..c011e04 100644 --- a/tests/custom/01_arithmetic/02_modulo +++ b/tests/custom/01_arithmetic/02_modulo @@ -1,32 +1,31 @@ -The utpl language supports modulo divisions, however they're only defined -for integer values. +The ucode language supports modulo divisions. -- Expect stdout -- If both operands are integers or convertible to integers, -the modulo division yields the remainder: +the modulo division yields the remaining integer value: 10 % 4 = 2 "10" % 4 = 2 10 % "4" = 2 "10" % "4" = 2 If either operand is a double value, the modulo operation -yields NaN: -10.0 % 4 = NaN -10 % 4.0 = NaN -"10.0" % 4 = NaN +yields the remaining value as calculated by fmod(3): +10.2 % 4 = 2.2 +10 % 4.3 = 1.4 +"10.4" % 4 = 2.4 -- End -- -- Testcase -- If both operands are integers or convertible to integers, -the modulo division yields the remainder: +the modulo division yields the remaining integer value: 10 % 4 = {{ 10 % 4 }} "10" % 4 = {{ "10" % 4 }} 10 % "4" = {{ 10 % 4 }} "10" % "4" = {{ "10" % "4" }} If either operand is a double value, the modulo operation -yields NaN: -10.0 % 4 = {{ 10.0 % 4 }} -10 % 4.0 = {{ 10 % 4.0 }} -"10.0" % 4 = {{ "10.0" % 4 }} +yields the remaining value as calculated by fmod(3): +10.2 % 4 = {{ 10.2 % 4 }} +10 % 4.3 = {{ 10 % 4.3 }} +"10.4" % 4 = {{ "10.4" % 4 }} -- End -- |