Source File
ftoa.go
Belonging Package
math/big
package big
import (
)
var decimal // == 0.0
switch {
.round(1 + )
:= [0]&2 == 0 // test bit 1 since original mantissa was shifted by 1
:= .mant
switch := uint(len(.mant)) * _W; {
case < :
= nat(nil).shl(, -)
case > :
= nat(nil).shr(, -)
}
:= int64(.exp) - 1 // avoid wrap-around
:= .utoa(16)
if debugFloat && [0] != '1' {
panic("incorrect mantissa: " + string())
}
= append(, "0x1"...)
if len() > 1 {
= append(, '.')
= append(, [1:]...)
}
= append(, 'p')
if >= 0 {
= append(, '+')
} else {
= -
= append(, '-')
:= .mant
:= 0
for < len() && [] == 0 {
++
}
= [:]
= append(, "0x."...)
= append(, bytes.TrimRight(.utoa(16), "0")...)
= append(, 'p')
if .exp >= 0 {
= append(, '+')
}
return strconv.AppendInt(, int64(.exp), 10)
}
func (, int) int {
if < {
return
}
return
}
var _ fmt.Formatter = &floatZero // *Float must implement fmt.Formatter
= 'f'
var string
switch {
case [0] == '-':
= "-"
= [1:]
writeMultiple(, , 1)
writeMultiple(, "0", )
.Write()
writeMultiple(, , 1)
.Write()
writeMultiple(, " ", )
writeMultiple(, " ", )
writeMultiple(, , 1)
.Write()
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |