1

I'm developing a website about Farm management. There are Detail and Edit Farm pages that user can edit the size(m2) of each Farm. Size is stored in DB as Float number.

There are some cases that user input a size as non floating-point number like: 1111111111111111 (length >= 16) then size will be stored in DB like 1.11111111111111E+15.

I am now looking for the way to show Size in Detail page as same as what user has inputed (without hexadecimal char and floating-point).

<td style="white-space:pre-wrap; word-wrap:break-word">@size.ToString()</td>

Now:

enter image description here

Expected:

enter image description here

Type of Size is double

Thanks!

vyclarks
  • 854
  • 2
  • 15
  • 39
  • typeof(size) in c# ? – Mate May 17 '19 at 04:36
  • it is double @Mate – vyclarks May 17 '19 at 04:37
  • Check https://jonskeet.uk/csharp/DoubleConverter.cs from https://csharpindepth.com/Articles/FloatingPoint ... another solutions: https://stackoverflow.com/questions/1546113/double-to-string-conversion-without-scientific-notation – Mate May 17 '19 at 04:41
  • use `decimal` and convert your string into number `@decimal.Parse("1.11111111111111E+15", System.Globalization.NumberStyles.Any).ToString()` – Lalji Dhameliya May 17 '19 at 05:05
  • it converts into a wrong number: 1111111111111110. It should be 1111111111111111 @LaljiDhameliya – vyclarks May 17 '19 at 05:27
  • you sure your exponentiation number is `1.11111111111111E+15` because you check it online it convert to `1111111111111110` this number https://www.free-online-calculator-use.com/scientific-notation-converter.html – Lalji Dhameliya May 17 '19 at 05:34
  • https://stackoverflow.com/questions/1421520/formatting-doubles-for-output-in-c-sharp – CodeCaster May 17 '19 at 06:12

0 Answers0