package encoding

import (
	
	
	
)

// EncodeFloat encodes a float value as per the stdlib encoder for json and xml protocol
// This encodes a float value into dst while attempting to conform to ES6 ToString for Numbers
//
// Based on encoding/json floatEncoder from the Go Standard Library
// https://golang.org/src/encoding/json/encode.go
func ( []byte,  float64,  int) []byte {
	if math.IsInf(, 0) || math.IsNaN() {
		panic(fmt.Sprintf("invalid float value: %s", strconv.FormatFloat(, 'g', -1, )))
	}

	 := math.Abs()
	 := byte('f')

	if  != 0 {
		if  == 64 && ( < 1e-6 ||  >= 1e21) ||  == 32 && (float32() < 1e-6 || float32() >= 1e21) {
			 = 'e'
		}
	}

	 = strconv.AppendFloat(, , , -1, )

	if  == 'e' {
		// clean up e-09 to e-9
		 := len()
		if  >= 4 && [-4] == 'e' && [-3] == '-' && [-2] == '0' {
			[-2] = [-1]
			 = [:-1]
		}
	}

	return 
}