Closed ghost closed 7 months ago
Did you try?
System.IO.Standard->SetFloatFormat(Number->Format->SCIENTIFIC);
0.12345678912345->PrintLine();
Output:
1.234568e-01
You misunderstood me. I want to have more digits in the decimal part like this:
0.12345678912345
1.1234567891234e-08
This is how C#'s Console.WriteLine
format the numbers by default.
I used the same code as you. And as you can see, the digits in the decimal part is too few: 1.234568e-01
. I want it to display the same as C#.
I was unable to match the C# output exactly.
One can use the SetFloatPrecision(..)
function to set precision; however, it is not guaranteed to decrement something like "e-1" to "e-2". The formatter may add another digit before "e-X" for example, "D.De-2" vs. "D.DDe-1". Underneath the hood, the runtime uses the C++ wstringstream
class for formatting, which uses the same function as std::wcout
.
value := 0.000004512345678912345;
String->SetFloatPrecision(2);
String->SetFloatFormat(Number->Format->SCIENTIFIC);
value->ToString()->PrintLine();
``
I'm currently using
System.IO.Standard->SetFloatFormat(System.Number->Format->SCIENTIFIC);
, but it doesn't work as expected.I want it to print into the screen like this: