dotnet / dotnet/machinelearning

Possible bug in DoubleParser.cs

Open
#7,181 0 comments 0 reactions 0 assignees View on GitHub
area-Core untriaged
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

In Microsoft.ML.Core\Utilities\DoubleParser.cs near lines 143 and 195

```csharp
int ichEnd;
if (!DoubleParser.TryParse(span.Slice(ich, span.Length - ich), out value, out ichEnd, flags))
{
value = default(Double);
return Result.Error;
}

// Make sure everything was consumed.
while (ichEnd < span.Length)
{
if (!char.IsWhiteSpace(span[ichEnd]))
return Result.Extra;
ichEnd++;
}
```
the ichEnd is indexed on the sliced span.
If ich is not 0 there will be an offset when for "ichEnd < span.Length" and "span[ichEnd]"

Example : for an input like " 1.234 " the method will return Result.Extra

Pössible solutions:
* ichEnd += ich;
* modify the tryparse to accept an offset and use the original span

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.