func frexp10Many(a, b, c *extFloat) (exp10 int) {
	exp10, i := c.frexp10()
	a.Multiply(powersOfTen[i])
	b.Multiply(powersOfTen[i])
	return
}
frexp10Many applies a common shift by a power of ten to a, b, c.
package v1
type extFloat struct {
	mant uint64
	exp  int
	neg  bool
}
const (
	firstPowerOfTen = -348
	stepPowerOfTen  = 8
)
var smallPowersOfTen = [...]extFloat{
	{1 << 63, -63, false},         
	{0xa << 60, -60, false},       
	{0x64 << 57, -57, false},      
	{0x3e8 << 54, -54, false},     
	{0x2710 << 50, -50, false},    
	{0x186a0 << 47, -47, false},   
	{0xf4240 << 44, -44, false},   
	{0x989680 << 40, -40, false},  
}
var powersOfTen = [...]extFloat{
	{0xfa8fd5a0081c0288, -1220, false},  
	{0xbaaee17fa23ebf76, -1193, false},  
	{0x8b16fb203055ac76, -1166, false},  
	{0xcf42894a5dce35ea, -1140, false},  
	{0x9a6bb0aa55653b2d, -1113, false},  
	{0xe61acf033d1a45df, -1087, false},  
	{0xab70fe17c79ac6ca, -1060, false},  
	{0xff77b1fcbebcdc4f, -1034, false},  
	{0xbe5691ef416bd60c, -1007, false},  
	{0x8dd01fad907ffc3c, -980, false},   
	{0xd3515c2831559a83, -954, false},   
	{0x9d71ac8fada6c9b5, -927, false},   
	{0xea9c227723ee8bcb, -901, false},   
	{0xaecc49914078536d, -874, false},   
	{0x823c12795db6ce57, -847, false},   
	{0xc21094364dfb5637, -821, false},   
	{0x9096ea6f3848984f, -794, false},   
	{0xd77485cb25823ac7, -768, false},   
	{0xa086cfcd97bf97f4, -741, false},   
	{0xef340a98172aace5, -715, false},   
	{0xb23867fb2a35b28e, -688, false},   
	{0x84c8d4dfd2c63f3b, -661, false},   
	{0xc5dd44271ad3cdba, -635, false},   
	{0x936b9fcebb25c996, -608, false},   
	{0xdbac6c247d62a584, -582, false},   
	{0xa3ab66580d5fdaf6, -555, false},   
	{0xf3e2f893dec3f126, -529, false},   
	{0xb5b5ada8aaff80b8, -502, false},   
	{0x87625f056c7c4a8b, -475, false},   
	{0xc9bcff6034c13053, -449, false},   
	{0x964e858c91ba2655, -422, false},   
	{0xdff9772470297ebd, -396, false},   
	{0xa6dfbd9fb8e5b88f, -369, false},   
	{0xf8a95fcf88747d94, -343, false},   
	{0xb94470938fa89bcf, -316, false},   
	{0x8a08f0f8bf0f156b, -289, false},   
	{0xcdb02555653131b6, -263, false},   
	{0x993fe2c6d07b7fac, -236, false},   
	{0xe45c10c42a2b3b06, -210, false},   
	{0xaa242499697392d3, -183, false},   
	{0xfd87b5f28300ca0e, -157, false},   
	{0xbce5086492111aeb, -130, false},   
	{0x8cbccc096f5088cc, -103, false},   
	{0xd1b71758e219652c, -77, false},    
	{0x9c40000000000000, -50, false},    
	{0xe8d4a51000000000, -24, false},    
	{0xad78ebc5ac620000, 3, false},      
	{0x813f3978f8940984, 30, false},     
	{0xc097ce7bc90715b3, 56, false},     
	{0x8f7e32ce7bea5c70, 83, false},     
	{0xd5d238a4abe98068, 109, false},    
	{0x9f4f2726179a2245, 136, false},    
	{0xed63a231d4c4fb27, 162, false},    
	{0xb0de65388cc8ada8, 189, false},    
	{0x83c7088e1aab65db, 216, false},    
	{0xc45d1df942711d9a, 242, false},    
	{0x924d692ca61be758, 269, false},    
	{0xda01ee641a708dea, 295, false},    
	{0xa26da3999aef774a, 322, false},    
	{0xf209787bb47d6b85, 348, false},    
	{0xb454e4a179dd1877, 375, false},    
	{0x865b86925b9bc5c2, 402, false},    
	{0xc83553c5c8965d3d, 428, false},    
	{0x952ab45cfa97a0b3, 455, false},    
	{0xde469fbd99a05fe3, 481, false},    
	{0xa59bc234db398c25, 508, false},    
	{0xf6c69a72a3989f5c, 534, false},    
	{0xb7dcbf5354e9bece, 561, false},    
	{0x88fcf317f22241e2, 588, false},    
	{0xcc20ce9bd35c78a5, 614, false},    
	{0x98165af37b2153df, 641, false},    
	{0xe2a0b5dc971f303a, 667, false},    
	{0xa8d9d1535ce3b396, 694, false},    
	{0xfb9b7cd9a4a7443c, 720, false},    
	{0xbb764c4ca7a44410, 747, false},    
	{0x8bab8eefb6409c1a, 774, false},    
	{0xd01fef10a657842c, 800, false},    
	{0x9b10a4e5e9913129, 827, false},    
	{0xe7109bfba19c0c9d, 853, false},    
	{0xac2820d9623bf429, 880, false},    
	{0x80444b5e7aa7cf85, 907, false},    
	{0xbf21e44003acdd2d, 933, false},    
	{0x8e679c2f5e44ff8f, 960, false},    
	{0xd433179d9c8cb841, 986, false},    
	{0x9e19db92b4e31ba9, 1013, false},   
	{0xeb96bf6ebadf77d9, 1039, false},   
	{0xaf87023b9bf0ee6b, 1066, false},   
}
func (f *extFloat) floatBits(flt *floatInfo) (bits uint64, overflow bool) {
	f.Normalize()
	exp := f.exp + 63
	if exp < flt.bias+1 {
		n := flt.bias + 1 - exp
		f.mant >>= uint(n)
		exp += n
	}
	mant := f.mant >> (63 - flt.mantbits)
	if f.mant&(1<<(62-flt.mantbits)) != 0 {
		mant += 1
	}
	if mant == 2<<flt.mantbits {
		mant >>= 1
		exp++
	}
	if exp-flt.bias >= 1<<flt.expbits-1 {
		mant = 0
		exp = 1<<flt.expbits - 1 + flt.bias
		overflow = true
	} else if mant&(1<<flt.mantbits) == 0 {
		exp = flt.bias
	}
	bits = mant & (uint64(1)<<flt.mantbits - 1)
	bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits
	if f.neg {
		bits |= 1 << (flt.mantbits + flt.expbits)
	}
	return
}
func (f *extFloat) AssignComputeBounds(mant uint64, exp int, neg bool, flt *floatInfo) (lower, upper extFloat) {
	f.mant = mant
	f.exp = exp - int(flt.mantbits)
	f.neg = neg
	if f.exp <= 0 && mant == (mant>>uint(-f.exp))<<uint(-f.exp) {
		f.mant >>= uint(-f.exp)
		f.exp = 0
		return *f, *f
	}
	expBiased := exp - flt.bias
	upper = extFloat{mant: 2*f.mant + 1, exp: f.exp - 1, neg: f.neg}
	if mant != 1<<flt.mantbits || expBiased == 1 {
		lower = extFloat{mant: 2*f.mant - 1, exp: f.exp - 1, neg: f.neg}
	} else {
		lower = extFloat{mant: 4*f.mant - 1, exp: f.exp - 2, neg: f.neg}
	}
	return
}
func (f *extFloat) Normalize() (shift uint) {
	mant, exp := f.mant, f.exp
	if mant == 0 {
		return 0
	}
	if mant>>(64-32) == 0 {
		mant <<= 32
		exp -= 32
	}
	if mant>>(64-16) == 0 {
		mant <<= 16
		exp -= 16
	}
	if mant>>(64-8) == 0 {
		mant <<= 8
		exp -= 8
	}
	if mant>>(64-4) == 0 {
		mant <<= 4
		exp -= 4
	}
	if mant>>(64-2) == 0 {
		mant <<= 2
		exp -= 2
	}
	if mant>>(64-1) == 0 {
		mant <<= 1
		exp -= 1
	}
	shift = uint(f.exp - exp)
	f.mant, f.exp = mant, exp
	return
}
func (f *extFloat) Multiply(g extFloat) {
	fhi, flo := f.mant>>32, uint64(uint32(f.mant))
	ghi, glo := g.mant>>32, uint64(uint32(g.mant))
	cross1 := fhi * glo
	cross2 := flo * ghi
	f.mant = fhi*ghi + (cross1 >> 32) + (cross2 >> 32)
	rem := uint64(uint32(cross1)) + uint64(uint32(cross2)) + ((flo * glo) >> 32)
	rem += (1 << 31)
	f.mant += (rem >> 32)
	f.exp = f.exp + g.exp + 64
}
var uint64pow10 = [...]uint64{
	1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
	1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
}
func (f *extFloat) AssignDecimal(mantissa uint64, exp10 int, neg bool, trunc bool, flt *floatInfo) (ok bool) {
	const uint64digits = 19
	const errorscale = 8
	errors := 0  
	if trunc {
		errors += errorscale / 2
	}
	f.mant = mantissa
	f.exp = 0
	f.neg = neg
	i := (exp10 - firstPowerOfTen) / stepPowerOfTen
	if exp10 < firstPowerOfTen || i >= len(powersOfTen) {
		return false
	}
	adjExp := (exp10 - firstPowerOfTen) % stepPowerOfTen
	if adjExp < uint64digits && mantissa < uint64pow10[uint64digits-adjExp] {
		f.mant *= uint64pow10[adjExp]
		f.Normalize()
	} else {
		f.Normalize()
		f.Multiply(smallPowersOfTen[adjExp])
		errors += errorscale / 2
	}
	f.Multiply(powersOfTen[i])
	if errors > 0 {
		errors += 1
	}
	errors += errorscale / 2
	shift := f.Normalize()
	errors <<= shift
	denormalExp := flt.bias - 63
	var extrabits uint
	if f.exp <= denormalExp {
		extrabits = uint(63 - flt.mantbits + 1 + uint(denormalExp-f.exp))
	} else {
		extrabits = uint(63 - flt.mantbits)
	}
	halfway := uint64(1) << (extrabits - 1)
	mant_extra := f.mant & (1<<extrabits - 1)
	if int64(halfway)-int64(errors) < int64(mant_extra) &&
		int64(mant_extra) < int64(halfway)+int64(errors) {
		return false
	}
	return true
}
func (f *extFloat) frexp10() (exp10, index int) {
	const expMin = -60
	const expMax = -32
	approxExp10 := ((expMin+expMax)/2 - f.exp) * 28 / 93  
	i := (approxExp10 - firstPowerOfTen) / stepPowerOfTen
Loop:
	for {
		exp := f.exp + powersOfTen[i].exp + 64
		switch {
		case exp < expMin:
			i++
		case exp > expMax:
			i--
		default:
			break Loop
		}
	}
	f.Multiply(powersOfTen[i])
	return -(firstPowerOfTen + i*stepPowerOfTen), i
}