Source File
floatmarsh.go
Belonging Package
math/big
package big
import (
)
const floatGobVersion byte = 1
:= 1 + 1 + 4 // version + mode|acc|form|neg (3+2+2+1bit) + prec
:= 0 // number of mantissa words
+= 4 + *_S // exp + mant
}
:= make([]byte, )
[0] = floatGobVersion
:= byte(.mode&7)<<5 | byte((.acc+1)&3)<<3 | byte(.form&3)<<1
if .neg {
|= 1
}
[1] =
binary.BigEndian.PutUint32([2:], .prec)
if .form == finite {
binary.BigEndian.PutUint32([6:], uint32(.exp))
.mant[len(.mant)-:].bytes([10:]) // cut off unused trailing words
}
return , nil
}
* = Float{}
return nil
}
if [0] != floatGobVersion {
return fmt.Errorf("Float.GobDecode: encoding version %d not supported", [0])
}
:= .prec
:= .mode
:= [1]
.mode = RoundingMode(( >> 5) & 7)
.acc = Accuracy((>>3)&3) - 1
.form = form(( >> 1) & 3)
.neg = &1 != 0
.prec = binary.BigEndian.Uint32([2:])
if .form == finite {
.exp = int32(binary.BigEndian.Uint32([6:]))
.mant = .mant.setBytes([10:])
}
if != 0 {
.mode =
.SetPrec(uint())
}
return nil
}
![]() |
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. |