package gojay

import (
	
)

var digits []int8

const maxInt64toMultiply = math.MaxInt64 / 10
const maxInt32toMultiply = math.MaxInt32 / 10
const maxInt16toMultiply = math.MaxInt16 / 10
const maxInt8toMultiply = math.MaxInt8 / 10
const maxUint8toMultiply = math.MaxUint8 / 10
const maxUint16toMultiply = math.MaxUint16 / 10
const maxUint32toMultiply = math.MaxUint32 / 10
const maxUint64toMultiply = math.MaxUint64 / 10
const maxUint32Length = 10
const maxUint64Length = 20
const maxUint16Length = 5
const maxUint8Length = 3
const maxInt32Length = 10
const maxInt64Length = 19
const maxInt16Length = 5
const maxInt8Length = 3
const invalidNumber = int8(-1)

var pow10uint64 = [21]uint64{
	0,
	1,
	10,
	100,
	1000,
	10000,
	100000,
	1000000,
	10000000,
	100000000,
	1000000000,
	10000000000,
	100000000000,
	1000000000000,
	10000000000000,
	100000000000000,
	1000000000000000,
	10000000000000000,
	100000000000000000,
	1000000000000000000,
	10000000000000000000,
}

var skipNumberEndCursorIncrement [256]int

func init() {
	digits = make([]int8, 256)
	for  := 0;  < len(digits); ++ {
		digits[] = invalidNumber
	}
	for  := int8('0');  <= int8('9'); ++ {
		digits[] =  - int8('0')
	}

	for  := 0;  < 256; ++ {
		switch  {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'e', 'E', '+', '-':
			skipNumberEndCursorIncrement[] = 1
		}
	}
}

func ( *Decoder) () (int, error) {
	 := .cursor + 1
	// look for following numbers
	for  := .cursor + 1;  < .length || .read(); ++ {
		 += skipNumberEndCursorIncrement[.data[]]

		switch .data[] {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'e', 'E', '+', '-', ' ', '\n', '\t', '\r':
			continue
		case ',', '}', ']':
			return , nil
		default:
			// invalid json we expect numbers, dot (single one), comma, or spaces
			return , .raiseInvalidJSONErr(.cursor)
		}
	}

	return , nil
}

func ( *Decoder) () (int64, error) {
	 := .cursor
	 := .cursor
	for ; .cursor < .length || .read(); .cursor++ {
		switch .data[.cursor] { // is positive
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			 = .cursor + 1
		case '-':
			.cursor++
			,  := .()
			return -, 
		case '+':
			.cursor++
			return .()
		default:
			// if nothing return 0
			// could raise error
			if  ==  {
				return 0, .raiseInvalidJSONErr(.cursor)
			}
			return .atoi64(, -1), nil
		}
	}
	if  ==  {

		return 0, .raiseInvalidJSONErr(.cursor)
	}
	return .atoi64(, -1), nil
}