File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -383,10 +383,42 @@ private static ReadOnlySpan<char> FindScaler(ReadOnlySpan<char> str, out float s
383383 str = TrimSeparator ( str ) ;
384384 scaler = 0 ;
385385
386+ bool hasDot = false ;
386387 for ( int i = 0 ; i < str . Length ; i ++ )
387388 {
388- if ( IsSeparator ( str [ i ] ) || i == str . Length )
389+ char ch = str [ i ] ;
390+
391+ if ( IsSeparator ( ch ) )
392+ {
393+ scaler = ParseFloat ( str [ ..i ] ) ;
394+ return str [ i ..] ;
395+ }
396+
397+ if ( ch == '.' )
398+ {
399+ if ( hasDot )
400+ {
401+ // Second decimal point starts a new number.
402+ scaler = ParseFloat ( str [ ..i ] ) ;
403+ return str [ i ..] ;
404+ }
405+
406+ hasDot = true ;
407+ }
408+ else if ( ( ch is '-' or '+' ) && i > 0 )
409+ {
410+ // A sign character mid-number starts a new number,
411+ // unless it follows an exponent indicator.
412+ char prev = str [ i - 1 ] ;
413+ if ( prev is not 'e' and not 'E' )
414+ {
415+ scaler = ParseFloat ( str [ ..i ] ) ;
416+ return str [ i ..] ;
417+ }
418+ }
419+ else if ( char . IsLetter ( ch ) )
389420 {
421+ // Hit a command letter; end this number.
390422 scaler = ParseFloat ( str [ ..i ] ) ;
391423 return str [ i ..] ;
392424 }
You can’t perform that action at this time.
0 commit comments