package gojay

// DecodeFloat64 reads the next JSON-encoded value from the decoder's input (io.Reader) and stores it in the float64 pointed to by v.
//
// See the documentation for Unmarshal for details about the conversion of JSON into a Go value.
func ( *Decoder) ( *float64) error {
	if .isPooled == 1 {
		panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder"))
	}
	return .decodeFloat64()
}
func ( *Decoder) ( *float64) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch  := .data[.cursor];  {
		case ' ', '\n', '\t', '\r', ',':
			continue
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			,  := .getFloat()
			if  != nil {
				return 
			}
			* = 
			return nil
		case '-':
			.cursor = .cursor + 1
			,  := .getFloatNegative()
			if  != nil {
				return 
			}
			* = -
			return nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return .raiseInvalidJSONErr(.cursor)
}
func ( *Decoder) ( **float64) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch  := .data[.cursor];  {
		case ' ', '\n', '\t', '\r', ',':
			continue
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			,  := .getFloat()
			if  != nil {
				return 
			}
			if * == nil {
				* = new(float64)
			}
			** = 
			return nil
		case '-':
			.cursor = .cursor + 1
			,  := .getFloatNegative()
			if  != nil {
				return 
			}
			if * == nil {
				* = new(float64)
			}
			** = -
			return nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () (float64, error) {
	// look for following numbers
	for ; .cursor < .length || .read(); .cursor++ {
		switch .data[.cursor] {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			return .getFloat()
		default:
			return 0, .raiseInvalidJSONErr(.cursor)
		}
	}
	return 0, .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () (float64, error) {
	var  = .cursor
	var  = .cursor
	// look for following numbers
	for  := .cursor + 1;  < .length || .read(); ++ {
		switch .data[] {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			 = 
			continue
		case '.':
			// we get part before decimal as integer
			 := .atoi64(, )
			// then we get part after decimal as integer
			 =  + 1
			// get number after the decimal point
			for  :=  + 1;  < .length || .read(); ++ {
				 := .data[]
				if isDigit() {
					 = 
					// multiply the before decimal point portion by 10 using bitwise
					// make sure it doesn't overflow
					if - < 18 {
						 = ( << 3) + ( << 1)
					}
					continue
				} else if ( == 'e' ||  == 'E') &&  < -1 {
					// we have an exponent, convert first the value we got before the exponent
					var  int64
					 :=  -  + 2
					// if exp is too long, it means number is too long, just truncate the number
					if  >= len(pow10uint64) ||  < 0 {
						 = len(pow10uint64) - 2
						 = .atoi64(, +-2)
					} else {
						// then we add both integers
						// then we divide the number by the power found
						 = .atoi64(, )
					}
					.cursor =  + 1
					 := pow10uint64[]
					 := float64(+) / float64()
					,  := .getExponent()
					if  != nil {
						return 0, 
					}
					 := ( + ( >> 31)) ^ ( >> 31) + 1 // absolute exponent
					if  >= int64(len(pow10uint64)) ||  < 0 {
						return 0, .raiseInvalidJSONErr(.cursor)
					}
					// if exponent is negative
					if  < 0 {
						return float64() * (1 / float64(pow10uint64[])), nil
					}
					return float64() * float64(pow10uint64[]), nil
				}
				.cursor = 
				break
			}
			if  >= .length ||  <  {
				return 0, .raiseInvalidJSONErr(.cursor)
			}
			var  int64
			 :=  -  + 2
			// if exp is too long, it means number is too long, just truncate the number
			if  >= len(pow10uint64) ||  < 0 {
				 = 19
				 = .atoi64(, +-2)
			} else {
				 = .atoi64(, )
			}

			 := pow10uint64[]
			// then we add both integers
			// then we divide the number by the power found
			return float64(+) / float64(), nil
		case 'e', 'E':
			.cursor =  + 1
			// we get part before decimal as integer
			 := uint64(.atoi64(, ))
			// get exponent
			,  := .getExponent()
			if  != nil {
				return 0, 
			}
			 := ( + ( >> 31)) ^ ( >> 31) + 1 // abs
			if  >= int64(len(pow10uint64)) ||  < 0 {
				return 0, .raiseInvalidJSONErr(.cursor)
			}
			// if exponent is negative
			if  < 0 {
				return float64() * (1 / float64(pow10uint64[])), nil
			}
			return float64() * float64(pow10uint64[]), nil
		case ' ', '\n', '\t', '\r', ',', '}', ']': // does not have decimal
			.cursor = 
			return float64(.atoi64(, )), nil
		}
		// invalid json we expect numbers, dot (single one), comma, or spaces
		return 0, .raiseInvalidJSONErr(.cursor)
	}
	return float64(.atoi64(, )), nil
}

// DecodeFloat32 reads the next JSON-encoded value from the decoder's input (io.Reader) and stores it in the float32 pointed to by v.
//
// See the documentation for Unmarshal for details about the conversion of JSON into a Go value.
func ( *Decoder) ( *float32) error {
	if .isPooled == 1 {
		panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder"))
	}
	return .decodeFloat32()
}
func ( *Decoder) ( *float32) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch  := .data[.cursor];  {
		case ' ', '\n', '\t', '\r', ',':
			continue
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			,  := .getFloat32()
			if  != nil {
				return 
			}
			* = 
			return nil
		case '-':
			.cursor = .cursor + 1
			,  := .getFloat32Negative()
			if  != nil {
				return 
			}
			* = -
			return nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return .raiseInvalidJSONErr(.cursor)
}
func ( *Decoder) ( **float32) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch  := .data[.cursor];  {
		case ' ', '\n', '\t', '\r', ',':
			continue
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			,  := .getFloat32()
			if  != nil {
				return 
			}
			if * == nil {
				* = new(float32)
			}
			** = 
			return nil
		case '-':
			.cursor = .cursor + 1
			,  := .getFloat32Negative()
			if  != nil {
				return 
			}
			if * == nil {
				* = new(float32)
			}
			** = -
			return nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () (float32, error) {
	// look for following numbers
	for ; .cursor < .length || .read(); .cursor++ {
		switch .data[.cursor] {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			return .getFloat32()
		default:
			return 0, .raiseInvalidJSONErr(.cursor)
		}
	}
	return 0, .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () (float32, error) {
	var  = .cursor
	var  = .cursor
	// look for following numbers
	for  := .cursor + 1;  < .length || .read(); ++ {
		switch .data[] {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
			 = 
			continue
		case '.':
			// we get part before decimal as integer
			 := .atoi64(, )
			// then we get part after decimal as integer
			 =  + 1
			// get number after the decimal point
			// multiple the before decimal point portion by 10 using bitwise
			for  :=  + 1;  < .length || .read(); ++ {
				 := .data[]
				if isDigit() {
					 = 
					// multiply the before decimal point portion by 10 using bitwise
					// make sure it desn't overflow
					if - < 9 {
						 = ( << 3) + ( << 1)
					}
					continue
				} else if ( == 'e' ||  == 'E') &&  < -1 {
					// we get the number before decimal
					var  int64
					 :=  -  + 2
					// if exp is too long, it means number is too long, just truncate the number
					if  >= 12 ||  < 0 {
						 = 10
						 = .atoi64(, +-2)
					} else {
						 = .atoi64(, )
					}
					.cursor =  + 1
					 := pow10uint64[]
					// then we add both integers
					// then we divide the number by the power found
					 := float32(+) / float32()
					,  := .getExponent()
					if  != nil {
						return 0, 
					}
					 := ( + ( >> 31)) ^ ( >> 31) + 1 // abs
					if  >= int64(len(pow10uint64)) ||  < 0 {
						return 0, .raiseInvalidJSONErr(.cursor)
					}
					// if exponent is negative
					if  < 0 {
						return float32() * (1 / float32(pow10uint64[])), nil
					}
					return float32() * float32(pow10uint64[]), nil
				}
				.cursor = 
				break
			}
			if  >= .length ||  <  {
				return 0, .raiseInvalidJSONErr(.cursor)
			}
			// then we add both integers
			// then we divide the number by the power found
			var  int64
			 :=  -  + 2
			// if exp is too long, it means number is too long, just truncate the number
			if  >= 12 ||  < 0 {
				 = 10
				 = .atoi64(, +-2)
			} else {
				// then we add both integers
				// then we divide the number by the power found
				 = .atoi64(, )
			}
			 := pow10uint64[]
			return float32(+) / float32(), nil
		case 'e', 'E':
			.cursor =  + 1
			// we get part before decimal as integer
			 := .atoi64(, )
			// get exponent
			,  := .getExponent()
			if  != nil {
				return 0, 
			}
			 := ( + ( >> 31)) ^ ( >> 31) + 1
			if  >= int64(len(pow10uint64)) ||  < 0 {
				return 0, .raiseInvalidJSONErr(.cursor)
			}
			// if exponent is negative
			if  < 0 {
				return float32() * (1 / float32(pow10uint64[])), nil
			}
			return float32() * float32(pow10uint64[]), nil
		case ' ', '\n', '\t', '\r', ',', '}', ']': // does not have decimal
			.cursor = 
			return float32(.atoi64(, )), nil
		}
		// invalid json we expect numbers, dot (single one), comma, or spaces
		return 0, .raiseInvalidJSONErr(.cursor)
	}
	return float32(.atoi64(, )), nil
}

// Add Values functions

// AddFloat decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float64) error {
	return .Float64()
}

// AddFloatNull decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
// If a `null` is encountered, gojay does not change the value of the pointer.
func ( *Decoder) ( **float64) error {
	return .Float64Null()
}

// AddFloat64 decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float64) error {
	return .Float64()
}

// AddFloat64Null decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
// If a `null` is encountered, gojay does not change the value of the pointer.
func ( *Decoder) ( **float64) error {
	return .Float64Null()
}

// AddFloat32 decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float32) error {
	return .Float32()
}

// AddFloat32Null decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
// If a `null` is encountered, gojay does not change the value of the pointer.
func ( *Decoder) ( **float32) error {
	return .Float32Null()
}

// Float decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float64) error {
	return .Float64()
}

// FloatNull decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( **float64) error {
	return .Float64Null()
}

// Float64 decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float64) error {
	 := .decodeFloat64()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}

// Float64Null decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( **float64) error {
	 := .decodeFloat64Null()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}

// Float32 decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( *float32) error {
	 := .decodeFloat32()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}

// Float32Null decodes the JSON value within an object or an array to a *float64.
// If next key value overflows float64, an InvalidUnmarshalError error will be returned.
func ( *Decoder) ( **float32) error {
	 := .decodeFloat32Null()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}