diff --git a/go/hexadecimal/hexadecimal.go b/go/hexadecimal/hexadecimal.go index 7330d76..30fb21e 100644 --- a/go/hexadecimal/hexadecimal.go +++ b/go/hexadecimal/hexadecimal.go @@ -45,7 +45,7 @@ func convertNumStringBase(in string, base int64) (int64, error) { } n += a - if n < 0 { + if n <= 0 && in[0] != '0' { return 0, errors.New("range") } } diff --git a/go/hexadecimal/hexadecimal_test.go b/go/hexadecimal/hexadecimal_test.go index f097057..241aacd 100644 --- a/go/hexadecimal/hexadecimal_test.go +++ b/go/hexadecimal/hexadecimal_test.go @@ -30,6 +30,7 @@ var testCases = []struct { {"2cg134", 0, "syntax"}, {"8000000000000000", 0, "range"}, {"9223372036854775809", 0, "range"}, + {"70000000000000000", 0, "range"}, } func TestParseHex(t *testing.T) {