1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math: digits panic for invalid base

This commit is contained in:
Daren Liang 2019-11-10 21:21:47 -05:00 committed by Alexander Medvednikov
parent 887c94d9ba
commit 91896af877

View File

@ -99,6 +99,9 @@ pub fn exp(a f64) f64 {
// digits returns an array of the digits of n in the given base. // digits returns an array of the digits of n in the given base.
pub fn digits(_n, base int) []int { pub fn digits(_n, base int) []int {
if base < 2 {
panic('digits: Cannot find digits of n with base $base')
}
mut n := _n mut n := _n
mut sign := 1 mut sign := 1
if n < 0 { if n < 0 {