MCPcopy Index your code
hub / github.com/pquerna/ffjson / Multiply

Method Multiply

fflib/v1/extfloat.go:235–251  ·  view source on GitHub ↗

Multiply sets f to the product f*g: the result is correctly rounded, but not normalized.

(g extFloat)

Source from the content-addressed store, hash-verified

233// Multiply sets f to the product f*g: the result is correctly rounded,
234// but not normalized.
235func (f *extFloat) Multiply(g extFloat) {
236 fhi, flo := f.mant>>32, uint64(uint32(f.mant))
237 ghi, glo := g.mant>>32, uint64(uint32(g.mant))
238
239 // Cross products.
240 cross1 := fhi * glo
241 cross2 := flo * ghi
242
243 // f.mant*g.mant is fhi*ghi << 64 + (cross1+cross2) << 32 + flo*glo
244 f.mant = fhi*ghi + (cross1 >> 32) + (cross2 >> 32)
245 rem := uint64(uint32(cross1)) + uint64(uint32(cross2)) + ((flo * glo) >> 32)
246 // Round up.
247 rem += (1 << 31)
248
249 f.mant += (rem >> 32)
250 f.exp = f.exp + g.exp + 64
251}
252
253var uint64pow10 = [...]uint64{
254 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,

Callers 3

AssignDecimalMethod · 0.95
frexp10Method · 0.95
frexp10ManyFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected