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.  How do check if a value is an integer?

    Employee
    Posted 07-22-2014 22:43

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

    Originally posted by: Patman

    How do check if a value is an integer?

    There is an isNumber() function but it returns true even for ".04" or "-3.1". Is there a function like an isInteger()?

    Thanks


  • 2.  RE: How do check if a value is an integer?

    Employee
    Posted 07-23-2014 06:36

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

    Originally posted by: DanRosenblatt

    BRAINscript does not have an isInteger function, but, the fieldType() function will return the value type of the field.

    If you have a field of numbers stored as strings, and you want to see which are whole numbers, you can accomplish this test by adding another condition to isNumber().

    Try something along the lines of

    ('field'.isNumber() and 'field'.double().floor() == 'field'.double())

    The floor() function evaluates to the largest integer less than or equal to the parameter, essentially removing anything after a decimal.