func TestDecodeBigReal(t *testing.T) {
	var hugeFloat big.Float
	hugeFloat.SetString("3.14e+99999")
	data := fmt.Sprintf("<real>%s</real>", hugeFloat.String())
	decoder := baseDecoder{nil, xml.NewDecoder(bytes.NewReader([]byte(data)))}

	value, err := decoder.NextValue()
	assert.NoError(t, err)
	assert.Equal(t, hugeFloat, value)
}
示例#2
0
func writeBigFloat(e *xml.Encoder, val *big.Float) error {
	return e.EncodeElement(val.String(), realStartElement)
}
示例#3
0
func floatToJSONNumber(f *big.Float) json.Number {
	return json.Number(f.String())
}