// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package jx

import (
	
	
)

// Float writes float value to buffer.
func ( *Writer) ( float64,  int) bool {
	if math.IsNaN() || math.IsInf(, 0) {
		// Like in ECMA:
		// NaN and Infinity regardless of sign are represented
		// as the String null.
		//
		// JSON.stringify({"foo":NaN}) -> {"foo":null}
		return .Null()
	}

	switch  := .stream; {
	case  == nil:
		.Buf = floatAppend(.Buf, , )
		return false
	case .fail():
		return true
	default:
		 := make([]byte, 0, 32)
		 = floatAppend(, , )
		return writeStreamByteseq(, )
	}
}

func ( []byte,  float64,  int) []byte {
	// From go std sources, strconv/ftoa.go:

	// Convert as if by ES6 number to string conversion.
	// This matches most other JSON generators.
	// See golang.org/issue/6384 and golang.org/issue/14135.
	// Like fmt %g, but the exponent cutoffs are different
	// and exponents themselves are not padded to two digits.
	 := math.Abs()
	 := byte('f')
	// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
	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 
}