Lines Matching full:mantissa

11 //   3) Multiply by 2^precision and round to get mantissa.
171 // readFloat reads a decimal or hexadecimal mantissa and exponent from a float
175 func readFloat(s string) (mantissa uint64, exp int, neg, trunc, hex bool, i int, ok bool) {
229 mantissa *= base
230 mantissa += uint64(c - '0')
241 mantissa *= 16
242 mantissa += uint64(lower(c) - 'a' + 10)
299 if mantissa != 0 {
429 func atof64exact(mantissa uint64, exp int, neg bool) (f float64, ok bool) {
430 if mantissa>>float64info.mantbits != 0 {
433 f = float64(mantissa)
461 // If possible to compute mantissa*10^exp to 32-bit float f exactly,
463 func atof32exact(mantissa uint64, exp int, neg bool) (f float32, ok bool) {
464 if mantissa>>float32info.mantbits != 0 {
467 f = float32(mantissa)
497 // The string s has already been parsed into a mantissa, exponent, and sign (neg==true for negative…
498 // If trunc is true, trailing non-zero bits have been omitted from the mantissa.
499 func atofHex(s string, flt *floatInfo, mantissa uint64, exp int, neg, trunc bool) (float64, error) {
502 exp += int(flt.mantbits) // mantissa now implicitly divided by 2^mantbits.
504 // Shift mantissa and exponent to bring representation into float range.
505 // Eventually we want a mantissa with a leading 1-bit followed by mantbits other bits.
508 // (If the mantissa has already lost non-zero bits, trunc is true,
510 for mantissa != 0 && mantissa>>(flt.mantbits+2) == 0 {
511 mantissa <<= 1
515 mantissa |= 1
517 for mantissa>>(1+flt.mantbits+2) != 0 {
518 mantissa = mantissa>>1 | mantissa&1
525 for mantissa > 1 && exp < minExp-2 {
526 mantissa = mantissa>>1 | mantissa&1
531 round := mantissa & 3
532 mantissa >>= 2
533 round |= mantissa & 1 // round to even (round up if mantissa is odd)
536 mantissa++
537 if mantissa == 1<<(1+flt.mantbits) {
538 mantissa >>= 1
543 if mantissa>>flt.mantbits == 0 { // Denormal or zero.
548 mantissa = 1 << flt.mantbits
553 bits := mantissa & (1<<flt.mantbits - 1)
571 mantissa, exp, neg, trunc, hex, n, ok := readFloat(s)
577 f, err := atofHex(s[:n], &float32info, mantissa, exp, neg, trunc)
585 if f, ok := atof32exact(mantissa, exp, neg); ok {
589 f, ok := eiselLemire32(mantissa, exp, neg)
594 // Even if the mantissa was truncated, we may
596 // converting the upper mantissa bound.
597 fUp, ok := eiselLemire32(mantissa+1, exp, neg)
622 mantissa, exp, neg, trunc, hex, n, ok := readFloat(s)
628 f, err := atofHex(s[:n], &float64info, mantissa, exp, neg, trunc)
636 if f, ok := atof64exact(mantissa, exp, neg); ok {
640 f, ok := eiselLemire64(mantissa, exp, neg)
645 // Even if the mantissa was truncated, we may
647 // converting the upper mantissa bound.
648 fUp, ok := eiselLemire64(mantissa+1, exp, neg)
680 // will fit in the mantissa.)