Source file src/internal/strconv/atof.go

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package strconv
     6  
     7  type floatInfo struct {
     8  	mantbits uint
     9  	expbits  uint
    10  	bias     int
    11  }
    12  
    13  var (
    14  	float32info = floatInfo{float32MantBits, float32ExpBits, float32Bias}
    15  	float64info = floatInfo{float64MantBits, float64ExpBits, float64Bias}
    16  )
    17  
    18  // decimal to binary floating point conversion.
    19  // Algorithm:
    20  //   1) Store input in multiprecision decimal.
    21  //   2) Multiply/divide decimal by powers of two until in range [0.5, 1)
    22  //   3) Multiply by 2^precision and round to get mantissa.
    23  
    24  var optimize = true // set to false to force slow-path conversions for testing
    25  
    26  // commonPrefixLenIgnoreCase returns the length of the common
    27  // prefix of s and prefix, with the character case of s ignored.
    28  // The prefix argument must be all lower-case.
    29  func commonPrefixLenIgnoreCase(s, prefix string) int {
    30  	n := min(len(prefix), len(s))
    31  	for i := 0; i < n; i++ {
    32  		c := s[i]
    33  		if 'A' <= c && c <= 'Z' {
    34  			c += 'a' - 'A'
    35  		}
    36  		if c != prefix[i] {
    37  			return i
    38  		}
    39  	}
    40  	return n
    41  }
    42  
    43  // special returns the floating-point value for the special,
    44  // possibly signed floating-point representations inf, infinity,
    45  // and NaN. The result is ok if a prefix of s contains one
    46  // of these representations and n is the length of that prefix.
    47  // The character case is ignored.
    48  func special(s string) (f float64, n int, ok bool) {
    49  	if len(s) == 0 {
    50  		return 0, 0, false
    51  	}
    52  	sign := 1
    53  	nsign := 0
    54  	switch s[0] {
    55  	case '+', '-':
    56  		if s[0] == '-' {
    57  			sign = -1
    58  		}
    59  		nsign = 1
    60  		s = s[1:]
    61  		fallthrough
    62  	case 'i', 'I':
    63  		n := commonPrefixLenIgnoreCase(s, "infinity")
    64  		// Anything longer than "inf" is ok, but if we
    65  		// don't have "infinity", only consume "inf".
    66  		if 3 < n && n < 8 {
    67  			n = 3
    68  		}
    69  		if n == 3 || n == 8 {
    70  			return inf(sign), nsign + n, true
    71  		}
    72  	case 'n', 'N':
    73  		if commonPrefixLenIgnoreCase(s, "nan") == 3 {
    74  			return nan(), 3, true
    75  		}
    76  	}
    77  	return 0, 0, false
    78  }
    79  
    80  func (b *decimal) set(s string) (ok bool) {
    81  	i := 0
    82  	b.neg = false
    83  	b.trunc = false
    84  
    85  	// optional sign
    86  	if i >= len(s) {
    87  		return
    88  	}
    89  	switch s[i] {
    90  	case '+':
    91  		i++
    92  	case '-':
    93  		i++
    94  		b.neg = true
    95  	}
    96  
    97  	// digits
    98  	sawdot := false
    99  	sawdigits := false
   100  	for ; i < len(s); i++ {
   101  		switch {
   102  		case s[i] == '_':
   103  			// readFloat already checked underscores
   104  			continue
   105  		case s[i] == '.':
   106  			if sawdot {
   107  				return
   108  			}
   109  			sawdot = true
   110  			b.dp = b.nd
   111  			continue
   112  
   113  		case '0' <= s[i] && s[i] <= '9':
   114  			sawdigits = true
   115  			if s[i] == '0' && b.nd == 0 { // ignore leading zeros
   116  				b.dp--
   117  				continue
   118  			}
   119  			if b.nd < len(b.d) {
   120  				b.d[b.nd] = s[i]
   121  				b.nd++
   122  			} else if s[i] != '0' {
   123  				b.trunc = true
   124  			}
   125  			continue
   126  		}
   127  		break
   128  	}
   129  	if !sawdigits {
   130  		return
   131  	}
   132  	if !sawdot {
   133  		b.dp = b.nd
   134  	}
   135  
   136  	// optional exponent moves decimal point.
   137  	// if we read a very large, very long number,
   138  	// just be sure to move the decimal point by
   139  	// a lot (say, 100000).  it doesn't matter if it's
   140  	// not the exact number.
   141  	if i < len(s) && lower(s[i]) == 'e' {
   142  		i++
   143  		if i >= len(s) {
   144  			return
   145  		}
   146  		esign := 1
   147  		switch s[i] {
   148  		case '+':
   149  			i++
   150  		case '-':
   151  			i++
   152  			esign = -1
   153  		}
   154  		if i >= len(s) || s[i] < '0' || s[i] > '9' {
   155  			return
   156  		}
   157  		e := 0
   158  		for ; i < len(s) && ('0' <= s[i] && s[i] <= '9' || s[i] == '_'); i++ {
   159  			if s[i] == '_' {
   160  				// readFloat already checked underscores
   161  				continue
   162  			}
   163  			if e < 10000 {
   164  				e = e*10 + int(s[i]) - '0'
   165  			}
   166  		}
   167  		b.dp += e * esign
   168  	}
   169  
   170  	if i != len(s) {
   171  		return
   172  	}
   173  
   174  	ok = true
   175  	return
   176  }
   177  
   178  // readFloat reads a decimal or hexadecimal mantissa and exponent from a float
   179  // string representation in s; the number may be followed by other characters.
   180  // readFloat reports the number of bytes consumed (i), and whether the number
   181  // is valid (ok).
   182  func readFloat(s string) (mantissa uint64, exp int, neg, trunc, hex bool, i int, ok bool) {
   183  	underscores := false
   184  
   185  	// optional sign
   186  	if i >= len(s) {
   187  		return
   188  	}
   189  	switch s[i] {
   190  	case '+':
   191  		i++
   192  	case '-':
   193  		i++
   194  		neg = true
   195  	}
   196  
   197  	// digits
   198  	base := uint64(10)
   199  	maxMantDigits := 19 // 10^19 fits in uint64
   200  	expChar := byte('e')
   201  	if i+2 < len(s) && s[i] == '0' && lower(s[i+1]) == 'x' {
   202  		base = 16
   203  		maxMantDigits = 16 // 16^16 fits in uint64
   204  		i += 2
   205  		expChar = 'p'
   206  		hex = true
   207  	}
   208  	sawdot := false
   209  	sawdigits := false
   210  	nd := 0
   211  	ndMant := 0
   212  	dp := 0
   213  loop:
   214  	for ; i < len(s); i++ {
   215  		switch c := s[i]; true {
   216  		case c == '_':
   217  			underscores = true
   218  			continue
   219  
   220  		case c == '.':
   221  			if sawdot {
   222  				break loop
   223  			}
   224  			sawdot = true
   225  			dp = nd
   226  			continue
   227  
   228  		case '0' <= c && c <= '9':
   229  			sawdigits = true
   230  			if c == '0' && nd == 0 { // ignore leading zeros
   231  				dp--
   232  				continue
   233  			}
   234  			nd++
   235  			if ndMant < maxMantDigits {
   236  				mantissa *= base
   237  				mantissa += uint64(c - '0')
   238  				ndMant++
   239  			} else if c != '0' {
   240  				trunc = true
   241  			}
   242  			continue
   243  
   244  		case base == 16 && 'a' <= lower(c) && lower(c) <= 'f':
   245  			sawdigits = true
   246  			nd++
   247  			if ndMant < maxMantDigits {
   248  				mantissa *= 16
   249  				mantissa += uint64(lower(c) - 'a' + 10)
   250  				ndMant++
   251  			} else {
   252  				trunc = true
   253  			}
   254  			continue
   255  		}
   256  		break
   257  	}
   258  	if !sawdigits {
   259  		return
   260  	}
   261  	if !sawdot {
   262  		dp = nd
   263  	}
   264  
   265  	if base == 16 {
   266  		dp *= 4
   267  		ndMant *= 4
   268  	}
   269  
   270  	// optional exponent moves decimal point.
   271  	// if we read a very large, very long number,
   272  	// just be sure to move the decimal point by
   273  	// a lot (say, 100000).  it doesn't matter if it's
   274  	// not the exact number.
   275  	if i < len(s) && lower(s[i]) == expChar {
   276  		i++
   277  		if i >= len(s) {
   278  			return
   279  		}
   280  		esign := 1
   281  		switch s[i] {
   282  		case '+':
   283  			i++
   284  		case '-':
   285  			i++
   286  			esign = -1
   287  		}
   288  		if i >= len(s) || s[i] < '0' || s[i] > '9' {
   289  			return
   290  		}
   291  		e := 0
   292  		for ; i < len(s) && ('0' <= s[i] && s[i] <= '9' || s[i] == '_'); i++ {
   293  			if s[i] == '_' {
   294  				underscores = true
   295  				continue
   296  			}
   297  			if e < 10000 {
   298  				e = e*10 + int(s[i]) - '0'
   299  			}
   300  		}
   301  		dp += e * esign
   302  	} else if base == 16 {
   303  		// Must have exponent.
   304  		return
   305  	}
   306  
   307  	if mantissa != 0 {
   308  		exp = dp - ndMant
   309  	}
   310  
   311  	if underscores && !underscoreOK(s[:i]) {
   312  		return
   313  	}
   314  
   315  	ok = true
   316  	return
   317  }
   318  
   319  // decimal power of ten to binary power of two.
   320  var powtab = []int{1, 3, 6, 9, 13, 16, 19, 23, 26}
   321  
   322  func (d *decimal) floatBits(flt *floatInfo) (b uint64, overflow bool) {
   323  	var exp int
   324  	var mant uint64
   325  
   326  	// Zero is always a special case.
   327  	if d.nd == 0 {
   328  		mant = 0
   329  		exp = flt.bias
   330  		goto out
   331  	}
   332  
   333  	// Obvious overflow/underflow.
   334  	// These bounds are for 64-bit floats.
   335  	// Will have to change if we want to support 80-bit floats in the future.
   336  	if d.dp > 310 {
   337  		goto overflow
   338  	}
   339  	if d.dp < -330 {
   340  		// zero
   341  		mant = 0
   342  		exp = flt.bias
   343  		goto out
   344  	}
   345  
   346  	// Scale by powers of two until in range [0.5, 1.0)
   347  	exp = 0
   348  	for d.dp > 0 {
   349  		var n int
   350  		if d.dp >= len(powtab) {
   351  			n = 27
   352  		} else {
   353  			n = powtab[d.dp]
   354  		}
   355  		d.Shift(-n)
   356  		exp += n
   357  	}
   358  	for d.dp < 0 || d.dp == 0 && d.d[0] < '5' {
   359  		var n int
   360  		if -d.dp >= len(powtab) {
   361  			n = 27
   362  		} else {
   363  			n = powtab[-d.dp]
   364  		}
   365  		d.Shift(n)
   366  		exp -= n
   367  	}
   368  
   369  	// Our range is [0.5,1) but floating point range is [1,2).
   370  	exp--
   371  
   372  	// Minimum representable exponent is flt.bias+1.
   373  	// If the exponent is smaller, move it up and
   374  	// adjust d accordingly.
   375  	if exp < flt.bias+1 {
   376  		n := flt.bias + 1 - exp
   377  		d.Shift(-n)
   378  		exp += n
   379  	}
   380  
   381  	if exp-flt.bias >= 1<<flt.expbits-1 {
   382  		goto overflow
   383  	}
   384  
   385  	// Extract 1+flt.mantbits bits.
   386  	d.Shift(int(1 + flt.mantbits))
   387  	mant = d.RoundedInteger()
   388  
   389  	// Rounding might have added a bit; shift down.
   390  	if mant == 2<<flt.mantbits {
   391  		mant >>= 1
   392  		exp++
   393  		if exp-flt.bias >= 1<<flt.expbits-1 {
   394  			goto overflow
   395  		}
   396  	}
   397  
   398  	// Denormalized?
   399  	if mant&(1<<flt.mantbits) == 0 {
   400  		exp = flt.bias
   401  	}
   402  	goto out
   403  
   404  overflow:
   405  	// ±Inf
   406  	mant = 0
   407  	exp = 1<<flt.expbits - 1 + flt.bias
   408  	overflow = true
   409  
   410  out:
   411  	// Assemble bits.
   412  	bits := mant & (uint64(1)<<flt.mantbits - 1)
   413  	bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits
   414  	if d.neg {
   415  		bits |= 1 << flt.mantbits << flt.expbits
   416  	}
   417  	return bits, overflow
   418  }
   419  
   420  // Exact powers of 10.
   421  var float64pow10 = []float64{
   422  	1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
   423  	1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
   424  	1e20, 1e21, 1e22,
   425  }
   426  var float32pow10 = []float32{1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10}
   427  
   428  // If possible to convert decimal representation to 64-bit float f exactly,
   429  // entirely in floating-point math, do so, avoiding the expense of decimalToFloatBits.
   430  // Three common cases:
   431  //
   432  //	value is exact integer
   433  //	value is exact integer * exact power of ten
   434  //	value is exact integer / exact power of ten
   435  //
   436  // These all produce potentially inexact but correctly rounded answers.
   437  func atof64exact(mantissa uint64, exp int, neg bool) (f float64, ok bool) {
   438  	if mantissa>>float64info.mantbits != 0 {
   439  		return
   440  	}
   441  	f = float64(mantissa)
   442  	if neg {
   443  		f = -f
   444  	}
   445  	switch {
   446  	case exp == 0:
   447  		// an integer.
   448  		return f, true
   449  	// Exact integers are <= 10^15.
   450  	// Exact powers of ten are <= 10^22.
   451  	case exp > 0 && exp <= 15+22: // int * 10^k
   452  		// If exponent is big but number of digits is not,
   453  		// can move a few zeros into the integer part.
   454  		if exp > 22 {
   455  			f *= float64pow10[exp-22]
   456  			exp = 22
   457  		}
   458  		if f > 1e15 || f < -1e15 {
   459  			// the exponent was really too large.
   460  			return
   461  		}
   462  		return f * float64pow10[exp], true
   463  	case exp < 0 && exp >= -22: // int / 10^k
   464  		return f / float64pow10[-exp], true
   465  	}
   466  	return
   467  }
   468  
   469  // If possible to compute mantissa*10^exp to 32-bit float f exactly,
   470  // entirely in floating-point math, do so, avoiding the machinery above.
   471  func atof32exact(mantissa uint64, exp int, neg bool) (f float32, ok bool) {
   472  	if mantissa>>float32MantBits != 0 {
   473  		return
   474  	}
   475  	f = float32(mantissa)
   476  	if neg {
   477  		f = -f
   478  	}
   479  	switch {
   480  	case exp == 0:
   481  		return f, true
   482  	// Exact integers are <= 10^7.
   483  	// Exact powers of ten are <= 10^10.
   484  	case exp > 0 && exp <= 7+10: // int * 10^k
   485  		// If exponent is big but number of digits is not,
   486  		// can move a few zeros into the integer part.
   487  		if exp > 10 {
   488  			f *= float32pow10[exp-10]
   489  			exp = 10
   490  		}
   491  		if f > 1e7 || f < -1e7 {
   492  			// the exponent was really too large.
   493  			return
   494  		}
   495  		return f * float32pow10[exp], true
   496  	case exp < 0 && exp >= -10: // int / 10^k
   497  		return f / float32pow10[-exp], true
   498  	}
   499  	return
   500  }
   501  
   502  // atofHex converts the hex floating-point string s
   503  // to a rounded float32 or float64 value (depending on flt==&float32info or flt==&float64info)
   504  // and returns it as a float64.
   505  // The string s has already been parsed into a mantissa, exponent, and sign (neg==true for negative).
   506  // If trunc is true, trailing non-zero bits have been omitted from the mantissa.
   507  func atofHex(s string, flt *floatInfo, mantissa uint64, exp int, neg, trunc bool) (float64, error) {
   508  	maxExp := 1<<flt.expbits + flt.bias - 2
   509  	minExp := flt.bias + 1
   510  	exp += int(flt.mantbits) // mantissa now implicitly divided by 2^mantbits.
   511  
   512  	// Shift mantissa and exponent to bring representation into float range.
   513  	// Eventually we want a mantissa with a leading 1-bit followed by mantbits other bits.
   514  	// For rounding, we need two more, where the bottom bit represents
   515  	// whether that bit or any later bit was non-zero.
   516  	// (If the mantissa has already lost non-zero bits, trunc is true,
   517  	// and we OR in a 1 below after shifting left appropriately.)
   518  	for mantissa != 0 && mantissa>>(flt.mantbits+2) == 0 {
   519  		mantissa <<= 1
   520  		exp--
   521  	}
   522  	if trunc {
   523  		mantissa |= 1
   524  	}
   525  	for mantissa>>(1+flt.mantbits+2) != 0 {
   526  		mantissa = mantissa>>1 | mantissa&1
   527  		exp++
   528  	}
   529  
   530  	// If exponent is too negative,
   531  	// denormalize in hopes of making it representable.
   532  	// (The -2 is for the rounding bits.)
   533  	for mantissa > 1 && exp < minExp-2 {
   534  		mantissa = mantissa>>1 | mantissa&1
   535  		exp++
   536  	}
   537  
   538  	// Round using two bottom bits.
   539  	round := mantissa & 3
   540  	mantissa >>= 2
   541  	round |= mantissa & 1 // round to even (round up if mantissa is odd)
   542  	exp += 2
   543  	if round == 3 {
   544  		mantissa++
   545  		if mantissa == 1<<(1+flt.mantbits) {
   546  			mantissa >>= 1
   547  			exp++
   548  		}
   549  	}
   550  
   551  	if mantissa>>flt.mantbits == 0 { // Denormal or zero.
   552  		exp = flt.bias
   553  	}
   554  	var err error
   555  	if exp > maxExp { // infinity and range error
   556  		mantissa = 1 << flt.mantbits
   557  		exp = maxExp + 1
   558  		err = ErrRange
   559  	}
   560  
   561  	bits := mantissa & (1<<flt.mantbits - 1)
   562  	bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits
   563  	if neg {
   564  		bits |= 1 << flt.mantbits << flt.expbits
   565  	}
   566  	if flt == &float32info {
   567  		return float64(float32frombits(uint32(bits))), err
   568  	}
   569  	return float64frombits(bits), err
   570  }
   571  
   572  const fnParseFloat = "ParseFloat"
   573  
   574  func atof32(s string) (f float32, n int, err error) {
   575  	if val, n, ok := special(s); ok {
   576  		return float32(val), n, nil
   577  	}
   578  
   579  	d, p, neg, trunc, hex, n, ok := readFloat(s)
   580  	if !ok {
   581  		return 0, n, ErrSyntax
   582  	}
   583  
   584  	if hex {
   585  		f, err := atofHex(s[:n], &float32info, d, p, neg, trunc)
   586  		return float32(f), n, err
   587  	}
   588  
   589  	if optimize {
   590  		sign := bool2[uint32](neg) << 31
   591  		if d == 0 {
   592  			return float32frombits(sign | 0), n, nil
   593  		}
   594  		if p > 40 { // overflow to ±Inf
   595  			return float32frombits(sign | 0xff<<23), n, ErrRange
   596  		}
   597  		if p < -70 { // underflow to ±0
   598  			return float32frombits(sign | 0), n, nil
   599  		}
   600  		if !trunc {
   601  			// Exact rounding with single multiplication or division.
   602  			if f, ok := atof32exact(d, p, neg); ok {
   603  				return f, n, nil
   604  			}
   605  		}
   606  		// Use fast unrounded scaling.
   607  		// The only possible err is ErrRange, when the result overflows to ±Inf.
   608  		f, err := parseFloat32(d, p, sign)
   609  		if !trunc {
   610  			return f, n, err
   611  		}
   612  		// If additional digits were truncated from d
   613  		// but d+1 converts to the same value,
   614  		// then the additional digits don't matter.
   615  		f1, _ := parseFloat32(d+1, p, sign)
   616  		if f == f1 {
   617  			return f, n, err
   618  		}
   619  	}
   620  
   621  	// Slow fallback.
   622  	var dec decimal
   623  	if !dec.set(s[:n]) {
   624  		return 0, n, ErrSyntax
   625  	}
   626  	b, ovf := dec.floatBits(&float32info)
   627  	f = float32frombits(uint32(b))
   628  	if ovf {
   629  		err = ErrRange
   630  	}
   631  	return f, n, err
   632  }
   633  
   634  func atof64(s string) (f float64, n int, err error) {
   635  	if val, n, ok := special(s); ok {
   636  		return val, n, nil
   637  	}
   638  
   639  	d, p, neg, trunc, hex, n, ok := readFloat(s)
   640  	if !ok {
   641  		return 0, n, ErrSyntax
   642  	}
   643  	if hex {
   644  		f, err := atofHex(s[:n], &float64info, d, p, neg, trunc)
   645  		return f, n, err
   646  	}
   647  	if optimize {
   648  		sign := bool2[uint64](neg) << 63
   649  		if d == 0 {
   650  			return float64frombits(sign | 0), n, nil
   651  		}
   652  		if p > 310 { // overflow to ±Inf
   653  			return float64frombits(sign | 0x7ff<<52), n, ErrRange
   654  		}
   655  		if p < -345 { // underflow to ±0
   656  			return float64frombits(sign | 0), n, nil
   657  		}
   658  		if !trunc {
   659  			// Exact rounding with single multiplication or division.
   660  			if f, ok := atof64exact(d, p, neg); ok {
   661  				return f, n, nil
   662  			}
   663  		}
   664  		// Use fast unrounded scaling.
   665  		// The only possible err is ErrRange, when the result overflows to ±Inf.
   666  		f, err := parseFloat64(d, p, sign)
   667  		if !trunc {
   668  			return f, n, err
   669  		}
   670  		// If additional digits were truncated from d
   671  		// but d+1 converts to the same value,
   672  		// then the additional digits don't matter.
   673  		f1, _ := parseFloat64(d+1, p, sign)
   674  		if f == f1 {
   675  			return f, n, err
   676  		}
   677  	}
   678  
   679  	// Slow fallback.
   680  	var dec decimal
   681  	if !dec.set(s[:n]) {
   682  		return 0, n, ErrSyntax
   683  	}
   684  	b, ovf := dec.floatBits(&float64info)
   685  	f = float64frombits(b)
   686  	if ovf {
   687  		err = ErrRange
   688  	}
   689  	return f, n, err
   690  }
   691  
   692  // ParseFloat converts the string s to a floating-point number
   693  // with the precision specified by bitSize: 32 for float32, or 64 for float64.
   694  // When bitSize=32, the result still has type float64, but it will be
   695  // convertible to float32 without changing its value.
   696  //
   697  // ParseFloat accepts decimal and hexadecimal floating-point numbers
   698  // as defined by the Go syntax for [floating-point literals].
   699  // If s is well-formed and near a valid floating-point number,
   700  // ParseFloat returns the nearest floating-point number rounded
   701  // using IEEE754 unbiased rounding.
   702  // (Parsing a hexadecimal floating-point value only rounds when
   703  // there are more bits in the hexadecimal representation than
   704  // will fit in the mantissa.)
   705  //
   706  // The errors that ParseFloat returns have concrete type *NumError
   707  // and include err.Num = s.
   708  //
   709  // If s is not syntactically well-formed, ParseFloat returns err.Err = ErrSyntax.
   710  //
   711  // If s is syntactically well-formed but is more than 1/2 ULP
   712  // away from the largest floating point number of the given size,
   713  // ParseFloat returns f = ±Inf, err.Err = ErrRange.
   714  //
   715  // ParseFloat recognizes the string "NaN", and the (possibly signed) strings "Inf" and "Infinity"
   716  // as their respective special floating point values. It ignores case when matching.
   717  //
   718  // [floating-point literals]: https://go.dev/ref/spec#Floating-point_literals
   719  func ParseFloat(s string, bitSize int) (float64, error) {
   720  	f, n, err := parseFloatPrefix(s, bitSize)
   721  	if n != len(s) {
   722  		return 0, ErrSyntax
   723  	}
   724  	return f, err
   725  }
   726  
   727  func parseFloatPrefix(s string, bitSize int) (float64, int, error) {
   728  	if bitSize == 32 {
   729  		f, n, err := atof32(s)
   730  		return float64(f), n, err
   731  	}
   732  	return atof64(s)
   733  }
   734  

View as plain text