SugarCRM Decimal Field

Hi All,

I have created the decimal type field using vardef where the length is 18 and precision is 15 which is also same in MySQL but when i try to update the field value up to 15 decimal like 34.1234567899876489, it is storing as rounded value up to 11 digit like 34.12345678999

Can someone let me know what exactly i need to do to achieve this.

Thanks 

Parents
  • Hi ,

    This was an interesting problem to solve and the problem lies with PHP precision settings (this is a bit different from MySQL).

    precision - The number of significant digits displayed in floating point numbers. -1 means that an enhanced algorithm for rounding such numbers will be used.

    The default value for precision is 14, so your number gets trimmed to 34.12345678999 (with 14 digits)

    In order to support more finer precision, you can increase the value in your php.ini to a larger number - which is 18 in your scenario.

    ; The number of significant digits displayed in floating point numbers.
    ; http://php.net/precision
    precision = 18

     

Reply
  • Hi ,

    This was an interesting problem to solve and the problem lies with PHP precision settings (this is a bit different from MySQL).

    precision - The number of significant digits displayed in floating point numbers. -1 means that an enhanced algorithm for rounding such numbers will be used.

    The default value for precision is 14, so your number gets trimmed to 34.12345678999 (with 14 digits)

    In order to support more finer precision, you can increase the value in your php.ini to a larger number - which is 18 in your scenario.

    ; The number of significant digits displayed in floating point numbers.
    ; http://php.net/precision
    precision = 18

     

Children