-2

I'm stuck with a problem and I have to display these numbers correctly using the power of ten. I know that the number in the end has to do with the fact that the decimal point is shifted the number to the right, only how I can do it or how I have to parse the number is a mystery to me. I have the numbers as a string

The whole thing is written in C #

"1.11632e+007"

"1.30357e+008"

The result must look like this The output can be as int or string does not matter

11163200

130357000

I have no idea how to do this. Can you help me?

Angelo223
  • 3
  • 3
  • Does this answer your question? [Find number of decimal places in decimal value regardless of culture](https://stackoverflow.com/questions/13477689/find-number-of-decimal-places-in-decimal-value-regardless-of-culture) – StPaulis May 17 '21 at 15:14
  • Can you include your code. It's not obvious if you need to parse a string to a number and then format it back to a string or if you're just having issues formatting an existing number to a string. – juharr May 17 '21 at 15:15
  • 1
    Does this answer your question? [Convert from scientific notation string to float](https://stackoverflow.com/questions/64639/convert-from-scientific-notation-string-to-float-in-c-sharp) & [Convert numbers with exponential notation from string to double/decimal](https://stackoverflow.com/questions/7877855/convert-numbers-with-exponential-notation-from-string-to-double-or-decimal) & [How to convert a string containing an exponential number to decimal and back to string](https://stackoverflow.com/questions/11663910/how-to-convert-a-string-containing-an-exponential-number-to-decimal-and-back-to) –  May 17 '21 at 15:21
  • `string result = doubleValue.ToString($"0.{new string('#', 339)}");` returns string representation of `double` value with no exponent – Dmitry Bychenko May 17 '21 at 15:29
  • `private static string DropExponent(string value) => double.Parse(value).ToString($"0.{new string('#', 339)}");` does the string conversion – Dmitry Bychenko May 17 '21 at 15:34
  • maybe I didn't express myself correctly. I have the point number as a string and after converting it should be a double – Angelo223 May 17 '21 at 18:09
  • My Problem is solved Thanks to @OlivierRogier thats worked for me. :D – Angelo223 May 17 '21 at 18:21

2 Answers2

0

the internal representation of a float is in binary, and there is nothing you can do about it.

If you want to print a float avoiding the scientific notation even for huge numbers it's something like

Console.WriteLine(x.ToString("F"));

-1

Assuming you are trying to parse it, System.Globalization.NumberStyles.Float should help:

var parsed = decimal.Parse("1.11632e+007", System.Globalization.NumberStyles.Float);
Console.WriteLine(parsed); // outputs "11163200"
umberto-petrov
  • 731
  • 4
  • 8
  • When I try the solution I get this error:System.FormatException: Input string was not in a correct format. – Angelo223 May 17 '21 at 18:06