VB.NET Converting a double value to a string = Exact loss

Hello, I have a double value similar to this in VB.NET:

Dim value = 9.729000000000001

When converting to a string, I get the following:

value.tostring() "9.729"

I am trying to add formatting:

value.tostring("0.00000000000000")

But this did not work (I am losing ending 1).

How can I save all my numbers?

+3
source share
1 answer

This is documented here and here.

try it

Dim value As Double = 9.729000000000001
Dim strText As String = value.ToString("G17")

Or that

Dim value As Double = 9.729000000000001
Dim strText As String = value.ToString("R")
+4
source

All Articles