package pgtype

import (
	
	
	
	
	

	
)

type Float8 struct {
	Float  float64
	Status Status
}

func ( *Float8) ( interface{}) error {
	if  == nil {
		* = Float8{Status: Null}
		return nil
	}

	if ,  := .(interface{ () interface{} });  {
		 := .()
		if  !=  {
			return .()
		}
	}

	switch value := .(type) {
	case float32:
		* = Float8{Float: float64(), Status: Present}
	case float64:
		* = Float8{Float: , Status: Present}
	case int8:
		* = Float8{Float: float64(), Status: Present}
	case uint8:
		* = Float8{Float: float64(), Status: Present}
	case int16:
		* = Float8{Float: float64(), Status: Present}
	case uint16:
		* = Float8{Float: float64(), Status: Present}
	case int32:
		* = Float8{Float: float64(), Status: Present}
	case uint32:
		* = Float8{Float: float64(), Status: Present}
	case int64:
		 := float64()
		if int64() ==  {
			* = Float8{Float: , Status: Present}
		} else {
			return fmt.Errorf("%v cannot be exactly represented as float64", )
		}
	case uint64:
		 := float64()
		if uint64() ==  {
			* = Float8{Float: , Status: Present}
		} else {
			return fmt.Errorf("%v cannot be exactly represented as float64", )
		}
	case int:
		 := float64()
		if int() ==  {
			* = Float8{Float: , Status: Present}
		} else {
			return fmt.Errorf("%v cannot be exactly represented as float64", )
		}
	case uint:
		 := float64()
		if uint() ==  {
			* = Float8{Float: , Status: Present}
		} else {
			return fmt.Errorf("%v cannot be exactly represented as float64", )
		}
	case string:
		,  := strconv.ParseFloat(, 64)
		if  != nil {
			return 
		}
		* = Float8{Float: float64(), Status: Present}
	case *float64:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *float32:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *int8:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *uint8:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *int16:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *uint16:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *int32:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *uint32:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *int64:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *uint64:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *int:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *uint:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	case *string:
		if  == nil {
			* = Float8{Status: Null}
		} else {
			return .(*)
		}
	default:
		if ,  := underlyingNumberType();  {
			return .()
		}
		return fmt.Errorf("cannot convert %v to Float8", )
	}

	return nil
}

func ( Float8) () interface{} {
	switch .Status {
	case Present:
		return .Float
	case Null:
		return nil
	default:
		return .Status
	}
}

func ( *Float8) ( interface{}) error {
	return float64AssignTo(.Float, .Status, )
}

func ( *Float8) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Float8{Status: Null}
		return nil
	}

	,  := strconv.ParseFloat(string(), 64)
	if  != nil {
		return 
	}

	* = Float8{Float: , Status: Present}
	return nil
}

func ( *Float8) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Float8{Status: Null}
		return nil
	}

	if len() != 8 {
		return fmt.Errorf("invalid length for float4: %v", len())
	}

	 := int64(binary.BigEndian.Uint64())

	* = Float8{Float: math.Float64frombits(uint64()), Status: Present}
	return nil
}

func ( Float8) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	 = append(, strconv.FormatFloat(float64(.Float), 'f', -1, 64)...)
	return , nil
}

func ( Float8) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	 = pgio.AppendUint64(, math.Float64bits(.Float))
	return , nil
}
Scan implements the database/sql Scanner interface.
func ( *Float8) ( interface{}) error {
	if  == nil {
		* = Float8{Status: Null}
		return nil
	}

	switch src := .(type) {
	case float64:
		* = Float8{Float: , Status: Present}
		return nil
	case string:
		return .DecodeText(nil, []byte())
	case []byte:
		 := make([]byte, len())
		copy(, )
		return .DecodeText(nil, )
	}

	return fmt.Errorf("cannot scan %T", )
}
Value implements the database/sql/driver Valuer interface.
func ( Float8) () (driver.Value, error) {
	switch .Status {
	case Present:
		return .Float, nil
	case Null:
		return nil, nil
	default:
		return nil, errUndefined
	}