Home C# store numbers like 10^-38 in an variable
Reply: 2

C# store numbers like 10^-38 in an variable

NeXuS Published in 2018-01-12 14:32:16Z

Dezimal and float cant store a number as small as 10^-38. Any suggestions on how I can save this number in a var.

peytonannett Reply to 2018-01-12 14:44:56Z

According to Microsoft's types and variables (https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/types-and-variables) you should be able to store that value in a double : 64 bits, range from 5.0 × 10^-324 to 1.7 × 10^308, with 15-digit precision

Ctznkane525 Reply to 2018-01-12 15:00:57Z

While there's no formal BigDecimal class in the .NET Framework, there are many implementations out there that have an underlying reference to BigInteger.

You won't get anywhere near the performance that you would with the simple data types like Decimal, Double or Float, but they should work.

A couple examples: https://gist.github.com/nberardi/2667136 https://github.com/Limeoats/BigDecimal

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316783 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO