summary refs log tree commit diff stats
path: root/compiler/saturate.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/saturate.nim')
-rw-r--r--compiler/saturate.nim22
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/saturate.nim b/compiler/saturate.nim
index 065cb5128..fe6e03c8b 100644
--- a/compiler/saturate.nim
+++ b/compiler/saturate.nim
@@ -15,33 +15,33 @@ proc `|+|`*(a, b: BiggestInt): BiggestInt =
   if (result xor a) >= 0'i64 or (result xor b) >= 0'i64:
     return result
   if a < 0 or b < 0:
-    result = low(result)
+    result = low(typeof(result))
   else:
-    result = high(result)
+    result = high(typeof(result))
 
 proc `|-|`*(a, b: BiggestInt): BiggestInt =
   result = a -% b
   if (result xor a) >= 0'i64 or (result xor not b) >= 0'i64:
     return result
   if b > 0:
-    result = low(result)
+    result = low(typeof(result))
   else:
-    result = high(result)
+    result = high(typeof(result))
 
 proc `|abs|`*(a: BiggestInt): BiggestInt =
-  if a != low(a):
+  if a != low(typeof(a)):
     if a >= 0: result = a
     else: result = -a
   else:
-    result = low(a)
+    result = low(typeof(a))
 
 proc `|div|`*(a, b: BiggestInt): BiggestInt =
-  # (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4) .. (5 div 1)
+  # (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4)..(5 div 1)
   if b == 0'i64:
     # make the same as ``div 1``:
     result = a
-  elif a == low(a) and b == -1'i64:
-    result = high(result)
+  elif a == low(typeof(a)) and b == -1'i64:
+    result = high(typeof(result))
   else:
     result = a div b
 
@@ -74,6 +74,6 @@ proc `|*|`*(a, b: BiggestInt): BiggestInt =
     return result
 
   if floatProd >= 0.0:
-    result = high(result)
+    result = high(typeof(result))
   else:
-    result = low(result)
+    result = low(typeof(result))