0

I have a SQLServer Database and when I import a float type, it's import an incorrect values:

DB value: 9.0 ES value: 90.0

DB Value: 16.00 ES value: 16000000000000004

I have setup a mapping for the value to float type and set the scale:2 parameter in river config without success.

Roopendra
  • 7,674
  • 16
  • 65
  • 92
David Sedeño
  • 495
  • 1
  • 6
  • 19

1 Answers1

1

My guess would be that somewhere along the line the value is parsed as a string and formatted in the wrong culture. E.g. if your decimal point is a comma, then a dot will be the thousands separator (most of the time) and will just be ignored:

PS> Get-Culture

LCID             Name             DisplayName
----             ----             -----------
1031             de-DE            German (Germany)


PS> [double]::Parse('9.0')
90

And the 16 doesn't seem to be an exact 16 which is why you'll get that ridiculously large number.

The easiest fix would be to change the locale on the server or your machine. The other option would be to figure out whether that's a bug in your code or the framework's. Generally it falls under common sense to always specify a culture (e.g. the invariant culture in .NET or the C locale in C) when formatting or parsing numbers intended for machine consumption but plenty of applications get that wrong too.

Joey
  • 344,408
  • 85
  • 689
  • 683