package strconv
import
type uint128 struct {
Hi uint64
Lo uint64
}
func (, uint64) uint128 {
, := bits.Mul64(, )
return uint128{, }
}
func ( uint64, uint128) (, , uint64) {
, := bits.Mul64(, .Lo)
, := bits.Mul64(, .Hi)
, := bits.Add64(, , 0)
return + , ,
}
func ( int) ( uint128, int, bool) {
if < pow10Min || > pow10Max {
return
}
return pow10Tab[-pow10Min], 1 + mulLog2_10(), true
}
func ( int) int {
return ( * 78913) >> 18
}
func ( int) int {
return ( * 108853) >> 15
}
func ( bool) uint {
if {
return 1
}
return 0
}
func ( uint64, int) bool {
return 1 <= && <= 22 && *div5Tab[-1][0] <= div5Tab[-1][1]
}
const maxUint64 = 1<<64 - 1
var div5Tab = [22][2]uint64{
{0xcccccccccccccccd, maxUint64 / 5},
{0x8f5c28f5c28f5c29, maxUint64 / 5 / 5},
{0x1cac083126e978d5, maxUint64 / 5 / 5 / 5},
{0xd288ce703afb7e91, maxUint64 / 5 / 5 / 5 / 5},
{0x5d4e8fb00bcbe61d, maxUint64 / 5 / 5 / 5 / 5 / 5},
{0x790fb65668c26139, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5},
{0xe5032477ae8d46a5, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xc767074b22e90e21, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x8e47ce423a2e9c6d, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x4fa7f60d3ed61f49, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x0fee64690c913975, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x3662e0e1cf503eb1, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xa47a2cf9f6433fbd, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x54186f653140a659, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x7738164770402145, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xe4a4d1417cd9a041, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xc75429d9e5c5200d, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xc1773b91fac10669, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x26b172506559ce15, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0xd489e3a9addec2d1, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x90e860bb892c8d5d, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
{0x502e79bf1b6f4f79, maxUint64 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5 / 5},
}
func ( uint64) (uint64, int) {
const (
= 0xc767074b22e90e21
= maxUint64 / 100000000
= 0xd288ce703afb7e91
= maxUint64 / 10000
= 0x8f5c28f5c28f5c29
= maxUint64 / 100
= 0xcccccccccccccccd
= maxUint64 / 10
)
var [1]struct{}
_ = [(*5*5*5*5*5*5*5*5)%(1<<64)-1]
_ = [(*5*5*5*5)%(1<<64)-1]
_ = [(*5*5)%(1<<64)-1]
_ = [(*5)%(1<<64)-1]
:= 0
for := bits.RotateLeft64(*, -8); <= ; = bits.RotateLeft64(*, -8) {
=
+= 8
}
if := bits.RotateLeft64(*, -4); <= {
=
+= 4
}
if := bits.RotateLeft64(*, -2); <= {
=
+= 2
}
if := bits.RotateLeft64(*, -1); <= {
=
+= 1
}
return ,
}