From 68ce2d0210d39bd6159b00a193f6304a04a154ee Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 23 Dec 2019 20:59:55 +0900 Subject: [PATCH] :bug: Fix random number digit --- src/faker/provider/util.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/faker/provider/util.nim b/src/faker/provider/util.nim index cdb128e..ac939f1 100644 --- a/src/faker/provider/util.nim +++ b/src/faker/provider/util.nim @@ -1,6 +1,7 @@ import macros, random from strformat import `&` from strutils import join, align +from math import `^` macro genProc*(names, modules: untyped): untyped = ## プロシージャ定義を生成する。 `names` がプロシージャ名、 `modules` はプロシ @@ -42,7 +43,8 @@ macro genProc*(names, modules: untyped): untyped = proc formatNumbers*(r: var Rand, format: string): string = proc alignFmt(r: var Rand, buf: string): string = - let num = $r.rand(1..buf.len) + let max = 10 ^ buf.len - 1 + let num = $r.rand(1..max) result = num.align(buf.len, '0') var buf: string