Scientific format

Scientific format

  
Hello

Does anybody knows a way to format a number with scientific notation?
There isn't any function like FormatDecimal().
ex: 2265416489 shows 2.27E9 or 2,27x109
Thanks

Antonio
Hello António,

As I know, there is no built-in method to do what you're asking.
I don't know your need but you can use javascript to do something like that using the method :  toExponential()

Example:

function myFunction(numb, myId)
{
    var num = numb;
    var x = document.getElementById(myId);
    x.innerHTML=num.toExponential();
}

HTML:

<p id="demo">Click the button to display the exponential notation of a specified number.</p>

Script Usage:

var n = "demo";
var num = 55.567666666666666666666689;

myFunction(num,n);

Result:

<p id="demo">5.55677e+1</p>

Another option is to do an extension with a method to do that..because it's simple...
You can do something like (just a simple example):
double value = 12345.6789;
Console.WriteLine(value.ToString("E", CultureInfo.InvariantCulture));
// Displays 1.234568E+004
Good luck and hope this helps..


Best Regards,
Gonçalo Martins
Worked like a charm :-)
Nice to know it, António..Simpler was difficult ;-)

Cheers,
Gonçalo M.