mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 10:31:47 +00:00
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:
@@ -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()
|
||||
Reference in New Issue
Block a user