LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Equalizing the number of decimals

    Employee
    Posted 10-15-2014 06:38

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Yingwai

    Hi all,

    My first question here at this great forum.

    I have a column named total count. In this column there are values with a different number of figures behind the comma.

    example:
    695.19
    43.234
    21.045
    7.5

    I want them to appear as follows:
    695.190
    43.234
    21.045
    7.500

    These values are currently displayed as Double.

    Does anybody have an answer for this?

    Thanks in advance!


  • 2.  RE: Equalizing the number of decimals

    Employee
    Posted 10-15-2014 06:55

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    As you are looking at these double values you are actually seeing a string representation of them. Internally they are stored in a binary form that itself is not consistent about the number of digits to the right of the decimal from one number to the next.

    So, in other words your question is about taking control over the way the numbers converted to string for reporting purposes. For this you can use the BRAINscript format() function. In your example, if the double field is named num you can get the string representation of that number formatted with 3 digits to the right of the decimal by using:
    format("%.03f",num)


  • 3.  RE: Equalizing the number of decimals

    Employee
    Posted 10-15-2014 06:57

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Yingwai

    Originally posted by: ejones
    					

    As you are looking at these double values you are actually seeing a string representation of them. Internally they are stored in a binary form that itself is not consistent about the number of digits to the right of the decimal from one number to the next.

    So, in other words your question is about taking control over the way the numbers converted to string for reporting purposes. For this you can use the BRAINscript format() function. In your example, if the double field is named num you can get the string representation of that number formatted with 3 digits to the right of the decimal by using:
    format("%.03f",num)
    Thanks so much for your quick reply ejones! Going to try it right away.