none
C# Help. RRS feed

  • Question

  • I was reading C# for Dummies and I wanted to know what does it mean that a decimal variable can represent a number between 10/-28 and 10/28?

    Thank you.

    Tuesday, July 24, 2018 1:04 AM

All replies

  • Greetings FUTURECIOAT.

    I'm not exactly sure what that means either. It looks like a funny way of expressing the precision and range.

    A decimal can represent a number from about minus ten to the power 28 to about plus ten to the power 28 (a negative number with 28 digits up to a positive number with 28 digits) and has a precision of about 28 digits (so if it's expressed as more digits, including those after the decimal place, the least significant ones won't be accurate).

    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/decimal

    Tuesday, July 24, 2018 1:31 AM
  • What they are trying to say is from 10 to the -28 power (0.0000000000000000000000000001) to 10 to the +28 power (actually 79,228,162,514,264,337,593,543,950,335), and the same range on the negative side.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Tuesday, July 24, 2018 6:22 AM
  • In c#, basically the range of decimal data type is (+ or -)1.0 x 10e-28 to 7.9 x 10e28. To know more about it check this url

    Data Types in C# with Examples

    Tuesday, July 24, 2018 1:41 PM
  • Hi FUTURECIOAT,

    It represent values ranging from -79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335 with 28 significant digits.

    All of this defined in .net framework source code. You could refer to the MSDN document for reference.

    https://referencesource.microsoft.com/#mscorlib/system/decimal.cs,02b40dbbd8665b0b

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 25, 2018 6:25 AM
    Moderator