How to use decimal digit more than 15 digit?

Posted by: lastday1225 on 8 September 2017, 2:47 pm EST

  • Posted 8 September 2017, 2:47 pm EST

    Hi, mate.

    I'd like to set the celltype digit to 19 digit.

     I found that farpoint sheet celltype (NumberCellType, GeneralCellType) not supported these features.

    Otherwise, MS Excel is supported maximum 30 digit.

    I think that probably farpoint is also supported these features.

    How to use decimal digit more than 15 digit?

  • Replied 8 September 2017, 2:47 pm EST

    Hello,

    The NumberCellType in Spread for Windows Forms only supports numbers
    with precision of 15 total digits with up to 7 of those 15 digits to the
    right of the decimal. Numbers outside this maximum range may or may not
    work correctly. I would suggest using CurrencyCellType instead. This
    will support numbers as decimal which has a much higher precision than
    doubles that are being used in the NumberCellType, it can take upto 29 digits with up to 7 digits to the left of the decimal and 22 digits to the right of the decimal.

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 2:47 pm EST

    lastday1225,

    In Excel, numbers are stored using the double data type. The double data type provides about 15 decimal digits of precision. Excel's number format allows up to 30 digits to the right of the decimal point.

    In Spread, the GeneralCellType is designed to work similar to Excel. Numbers are stored using the double data type just like Excel. You can format numbers with 30 digits to the right of the decimal point using either the NumberFormat property...

        GeneralCellType ct = new GeneralCellType();
        ct.NumberFormat = new System.Globalization.NumberFormatInfo();
        ct.NumberFormat.NumberDecimalDigits = 30;
        fpSpread1.Sheets[0].Cells[0, 0].CellType = ct;

    or the FormatString property...

        GeneralCellType ct = new GeneralCellType();
        ct.FormatString = "0.000000000000000000000000000000";
        fpSpread1.Sheets[0].Cells[0, 0].CellType = ct;

    In Spread, the NumberCellType is designed for working with number values that are stored using the double data type. The DecimalPlaces property is limited to 16 places (which is about the same as the precision of the double data type).

    In Spread, the CurrencyCellType is designed for working with number values that are stored using the decimal data type. The decimal data type provides about 28 decimal digits of precision. The DecimalPlaces property is limited to 29 places (which is about the same as the precision of the decimal data type).

  • Replied 8 September 2017, 2:47 pm EST

    I read this doc, IEEE 754.

    Thank you for helping me.

    But, as you might know, the CurrencyCellType is not enough supported it.

    Even if I use this celltype, also it is still limited to 16 places.

    If I use 16 decimal digits, do I need to think to  another idea?

    for example, convert text to number...?

    (In Spread, as TextCellType)123.1234567890123456789012345  --> another c# value type

  • Replied 8 September 2017, 2:47 pm EST

    lastday1225,

    The CurrencyCellType can handle more than 15 digits to the right of the decimal.  For example, the following code will display 25 digits to the right of the decimal place.

    CurrencyCellType ct = new CurrencyCellType();
    ct.DecimalPlaces = 25;
    fpSpread1.Sheets[0].Cells[0, 0].CellType = ct;
    fpSpread1.Sheets[0].Cells[0, 0].Value = 123.1234567890123456789012345m;

    Note that the code assigned a value of type Decimal. If the code had assigned a value of type Double then you would no see all 25 digits to the right of the decimal place because the Double data type only supports about 15 signficant digits.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels