Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use <code>value.ToString("N99").TrimEnd("0"c)</code> (99 is the largest number of digits the format specifier will work with).</p> <p>Or you could take the digits of the number and prepend them with the appropriate number of zeros, which will work for numbers smaller than 1E-99, although I don't think that would be easier on the user's eyes:</p> <pre><code>Module Module1 Function DoubleToString(x As Double) As String Dim sf As String = x.ToString() ' If the number would not be displayed in scientific format, there is no ' need to process it. Dim eLocation As Integer = sf.IndexOf({"E"c}, StringComparison.OrdinalIgnoreCase) If eLocation = -1 Then Return sf End If Dim decSeparator As Char = CChar(Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator) Dim magnitude As Integer = CInt(Math.Floor(Math.Log10(Math.Abs(x)))) If magnitude &lt; 0 Then Dim digits As String = (x * 10 ^ (-magnitude)).ToString().Replace(decSeparator, "") Dim sign As String = "" If x &lt; 0 Then sign = "-" digits = digits.Substring(1) End If Return String.Format("{0}0{1}{2}{3}", sign, decSeparator, New String("0"c, -magnitude - 1), digits) Else ' Could process it to display large numbers. Return sf End If End Function Sub Main() Dim value As Double = 0.00006214 ' A simple way. Console.WriteLine(value.ToString("N99").TrimEnd("0"c)) Console.WriteLine(DoubleToString(value)) Console.ReadLine() End Sub End Module </code></pre> <p>And <code>DoubleToString(1.23456789E-190)</code> gives <code>0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456789</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload