Skip to content

Commit 0fea414

Browse files
committed
making nint128 work again since Nim version 1.0.0
1 parent f11d9a7 commit 0fea414

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/nint128/comparisons/equal.nim

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import ../nint128_types, ../nint128_cint128
22

33
func nimEqual(x, y: UInt128): bool {.inline.} =
44
# (x.hi == y.hi) and (x.lo == y.lo)
5-
((x.lo xor y.lo) or (x.hi xor y.hi)) == 0 # Generates assembly code
6-
# practically the same as Cint128.
7-
# It has one less instruction.
8-
# Tested: amd64
5+
((x.lo xor y.lo) or (x.hi xor y.hi)) == 0'u64 # Generates assembly code
6+
# practically the same as
7+
# Cint128. It has one less
8+
# instruction. Tested: amd64
99

1010
func cEqual(x, y: UInt128): bool {.inline, used.} =
1111
let
@@ -16,10 +16,13 @@ func cEqual(x, y: UInt128): bool {.inline, used.} =
1616

1717
func nimEqual(x, y: Int128): bool {.inline.} =
1818
# (x.hi == y.hi) and (x.lo == y.lo)
19-
((x.lo xor y.lo) or uint64(x.hi xor y.hi)) == 0 # Generates assembly code
20-
# practically the same as
21-
# CInt128. It has one less
22-
# instruction. Tested: amd64
19+
((x.lo xor y.lo) or cast[uint64](x.hi xor y.hi)) == 0'u64 # Generates assembly
20+
# code practically
21+
# the same as
22+
# CInt128. It has
23+
# one less
24+
# instruction.
25+
# Tested: amd64
2326

2427
func cEqual(x, y: Int128): bool {.inline, used.} =
2528
let

src/nint128/comparisons/notequal.nim

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ func nimNotEqual(x, y: UInt128): bool {.inline.} =
44
# Using a unique proc for notequal, generates assembly code with one
55
# instruction unless using Nim's template. Tested: amd64
66
# (x.hi != y.hi) or (x.lo != y.lo)
7-
((x.lo xor y.lo) or (x.hi xor y.hi)) > 0 # Generates assembly code
8-
# practically the same as CUInt128.
9-
# It has one less instruction.
10-
# Tested: amd64
7+
((x.lo xor y.lo) or (x.hi xor y.hi)) > 0'u64 # Generates assembly code
8+
# practically the same as CUInt128.
9+
# It has one less instruction.
10+
# Tested: amd64
1111

1212
func cNotEqual(x, y: UInt128): bool {.inline, used.} =
1313
let
@@ -20,10 +20,12 @@ func nimNotEqual(x, y: Int128): bool {.inline.} =
2020
# Using a unique proc for notequal, generates assembly code with one
2121
# instruction unless using Nim's template. Tested: amd64
2222
# (x.hi != y.hi) or (x.lo != y.lo)
23-
((x.lo xor y.lo) or uint64(x.hi xor y.hi)) > 0 # Generates assembly code
24-
# practically the same as
25-
# CInt128. It has one less
26-
# instruction. Tested: amd64
23+
((x.lo xor y.lo) or cast[uint64](x.hi xor y.hi)) > 0'u64 # Generates assembly
24+
# code practically
25+
# the same as
26+
# CInt128. It has one
27+
# less instruction.
28+
# Tested: amd64
2729

2830
func cNotEqual(x, y: Int128): bool {.inline, used.} =
2931
let

0 commit comments

Comments
 (0)