fix warnings for deprecated low and high (#15291)

This commit is contained in:
Miran 2020-09-11 01:04:07 +02:00 • committed by GitHub
commit 6a621b35e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View file

@ -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)
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))