package jsoniter

import (
	
	
	
)

var pow10 []uint64

func init() {
	pow10 = []uint64{1, 10, 100, 1000, 10000, 100000, 1000000}
}

// WriteFloat32 write float32 to stream
func ( *Stream) ( float32) {
	if math.IsInf(float64(), 0) || math.IsNaN(float64()) {
		.Error = fmt.Errorf("unsupported value: %f", )
		return
	}
	 := math.Abs(float64())
	 := byte('f')
	// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
	if  != 0 {
		if float32() < 1e-6 || float32() >= 1e21 {
			 = 'e'
		}
	}
	.buf = strconv.AppendFloat(.buf, float64(), , -1, 32)
}

// WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
func ( *Stream) ( float32) {
	if math.IsInf(float64(), 0) || math.IsNaN(float64()) {
		.Error = fmt.Errorf("unsupported value: %f", )
		return
	}
	if  < 0 {
		.writeByte('-')
		 = -
	}
	if  > 0x4ffffff {
		.WriteFloat32()
		return
	}
	 := 6
	 := uint64(1000000) // 6
	 := uint64(float64()*float64() + 0.5)
	.WriteUint64( / )
	 :=  % 
	if  == 0 {
		return
	}
	.writeByte('.')
	for  :=  - 1;  > 0 &&  < pow10[]; -- {
		.writeByte('0')
	}
	.WriteUint64()
	for .buf[len(.buf)-1] == '0' {
		.buf = .buf[:len(.buf)-1]
	}
}

// WriteFloat64 write float64 to stream
func ( *Stream) ( float64) {
	if math.IsInf(, 0) || math.IsNaN() {
		.Error = fmt.Errorf("unsupported value: %f", )
		return
	}
	 := math.Abs()
	 := byte('f')
	// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
	if  != 0 {
		if  < 1e-6 ||  >= 1e21 {
			 = 'e'
		}
	}
	.buf = strconv.AppendFloat(.buf, float64(), , -1, 64)
}

// WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
func ( *Stream) ( float64) {
	if math.IsInf(, 0) || math.IsNaN() {
		.Error = fmt.Errorf("unsupported value: %f", )
		return
	}
	if  < 0 {
		.writeByte('-')
		 = -
	}
	if  > 0x4ffffff {
		.WriteFloat64()
		return
	}
	 := 6
	 := uint64(1000000) // 6
	 := uint64(*float64() + 0.5)
	.WriteUint64( / )
	 :=  % 
	if  == 0 {
		return
	}
	.writeByte('.')
	for  :=  - 1;  > 0 &&  < pow10[]; -- {
		.writeByte('0')
	}
	.WriteUint64()
	for .buf[len(.buf)-1] == '0' {
		.buf = .buf[:len(.buf)-1]
	}
}