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.  Rounding the decimal places

    Employee
    Posted 05-13-2010 22:59

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

    Originally posted by: yifeng

    Hi, I am a group of numbers that are Doubles and Intergers but i want to make them all Integers. So for the Doubles i need to round up the decimal places to the next higher Integer eg 2.1 will become 3. As for Integer i want to keep it as it is.

    Can you tell me how could i archive it? Thanks!


  • 2.  RE: Rounding the decimal places

    Employee
    Posted 05-14-2010 06:15

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

    Originally posted by: timonk

    Good Day,


    In BRAINScript, there is a function for evaluating to the smallest integer greater or equal to a parameter: "ceil"

    If you look in your BRAINScript Help (you can reach this from BRE under the Help menu), under the Numeric Operators section you fill see the "ceil" function

    CEIL:
    Finds the ceiling of a number: Evaluates to the smallest integer greater than or equal ot the parameter.

    ceil(num) or num.ceil()

    So for example:
    ceil(1.01) = 2.0
    2.3.ceil() = 3.0
    ceil(4.56) = 5.0
    ceil(5) = 5.0

    Now, if you want these to be integers, you can simply combine with the "int" function

    int(ceil(1.0.1)) = 2
    int(2.3.ceil()) = 3

    I recommend reviewing your BRAINScript help for more information on the various functions provided.

    Regards
    Timon Koufopoulos
    MDA Support


  • 3.  RE: Rounding the decimal places

    Employee
    Posted 05-17-2010 17:03

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

    Originally posted by: yifeng

    Thank you for your help