Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for roundShortest (0.19 sec)

  1. src/strconv/ftoa.go

    		}
    		return fmtF(dst, neg, digs, max(prec-digs.dp, 0))
    	}
    
    	// unknown format
    	return append(dst, '%', fmt)
    }
    
    // roundShortest rounds d (= mant * 2^exp) to the shortest number of digits
    // that will let the original floating point value be precisely reconstructed.
    func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) {
    	// If mantissa is zero, the number is zero; stop now.
    	if mant == 0 {
    		d.nd = 0
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Apr 04 14:21:28 UTC 2024
    - 13.9K bytes
    - Viewed (0)
  2. src/math/big/ftoa.go

    	var d decimal // == 0.0
    	if x.form == finite {
    		// x != 0
    		d.init(x.mant, int(x.exp)-x.mant.bitLen())
    	}
    
    	// 2) round to desired precision
    	shortest := false
    	if prec < 0 {
    		shortest = true
    		roundShortest(&d, x)
    		// Precision for shortest representation mode.
    		switch fmt {
    		case 'e', 'E':
    			prec = len(d.mant) - 1
    		case 'f':
    			prec = max(len(d.mant)-d.exp, 0)
    		case 'g', 'G':
    			prec = len(d.mant)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 13.5K bytes
    - Viewed (0)
Back to top