File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -144,20 +144,20 @@ func (n *Numeric) toBigInt() (*big.Int, error) {
144144}
145145
146146func parseNumericString (str string ) (n * big.Int , exp int32 , err error ) {
147- parts := strings .SplitN (str , "." , 2 )
148- digits := strings .Join (parts , "" )
147+ idx := strings .IndexByte (str , '.' )
149148
150- if len (parts ) > 1 {
151- exp = int32 (- len (parts [1 ]))
152- } else {
153- for len (digits ) > 1 && digits [len (digits )- 1 ] == '0' && digits [len (digits )- 2 ] != '-' {
154- digits = digits [:len (digits )- 1 ]
149+ if idx == - 1 {
150+ for len (str ) > 1 && str [len (str )- 1 ] == '0' && str [len (str )- 2 ] != '-' {
151+ str = str [:len (str )- 1 ]
155152 exp ++
156153 }
154+ } else {
155+ exp = int32 (- (len (str ) - idx - 1 ))
156+ str = str [:idx ] + str [idx + 1 :]
157157 }
158158
159159 accum := & big.Int {}
160- if _ , ok := accum .SetString (digits , 10 ); ! ok {
160+ if _ , ok := accum .SetString (str , 10 ); ! ok {
161161 return nil , 0 , fmt .Errorf ("%s is not a number" , str )
162162 }
163163
You can’t perform that action at this time.
0 commit comments