code: func getValidFloatPrefix(sc *variable.StatementContext, s string) (valid string, err error) {
  	var (
  		sawDot   bool
  		sawDigit bool
  		validLen int
  		eIdx     int
  	)
  	for i := 0; i < len(s); i++ {
  		c := s[i]
  		if c == '+' || c == '-' {
  			if i != 0 && i != eIdx+1 { // "1e+1" is valid.
  				break
  			}
  		} else if c == '.' {
  			if sawDot || eIdx > 0 { // "1.1." or "1e1.1"
  				break
  			}
  			sawDot = true
  			if sawDigit { // "123." is valid.
  				validLen = i + 1
  			}
  		} else if c == 'e' || c == 'E' {
  			if !sawDigit { // "+.e"
  				break
  			}
  			if eIdx != 0 { // "1e5e"
  				break
  			}
  			eIdx = i
  		} else if c < '0' || c > '9' {
  			break
  		} else {
  			sawDigit = true
  			validLen = i + 1
  		}
  	}
  	valid = s[:validLen]
  	if valid == "" {
  		valid = "0"
  	}
  	if validLen == 0 || validLen != len(s) {
  		err = errors.Trace(handleTruncateError(sc))
  	}
  	return valid, err
  }
docs: // getValidFloatPrefix gets prefix of string which can be successfully parsed as float.