Not understanding this: Number returned from DataReader: 185549633.66000035
We have a requirement to maintain the number of decimal places per a User Choice.
For example: maintain 7 places.
We are using:
FormatNumber(dr.Item("Field"), 7, TriState.false, , TriState.True)
The result is: 185,549,633.6600000. We would like to maintain the 3 (or 35) at the end.
When subtracting two numbers from the resulting query we are getting a delta but trying to show these two numbers out to 6,7,8 digits is not working thus indicating a false delta to the user.
Any advice would be appreciated.
Based on my testing, you must be working with
Double
values rather thanDecimal
. Not surprisingly, the solution to your problem can be found in the documentation.For a start, you should not be using
FormatNumber
. We're not in VB6 anymore ToTo. To format a number in VB.NET, callToString
on that number. I tested this:and I saw the behaviour you describe, i.e. the output was:
I read the documentation for the
Double.ToString
method (note thatFormatNumber
would be callingToString
internally) and this is what it says:I then tested this:
and the result was: