Simplify addInt, remove digits10 (#18356)

* Simplify addInt, remove digits10

Co-authored-by: Charles Blake <charlechaud@gmail.com>

* Fix bootstrapping

* Add noInit to tmp array

* noInit -> noinit

Co-authored-by: Charles Blake <charlechaud@gmail.com>
This commit is contained in:
Clyybber
2021-06-28 15:00:14 +02:00
committed by GitHub
parent e720bbdd76
commit 6e74fecb42
4 changed files with 27 additions and 68 deletions

View File

@@ -1,23 +0,0 @@
import std/private/digitsutils
template main =
block: # digits10
doAssert digits10(0'u64) == 1
# checks correctness on all powers of 10 + [0,-1,1]
var x = 1'u64
var num = 1
while true:
# echo (x, num)
doAssert digits10(x) == num
doAssert digits10(x+1) == num
if x > 1:
doAssert digits10(x-1) == num - 1
num += 1
let xOld = x
x *= 10
if x < xOld:
# wrap-around
break
static: main()
main()