Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Location
    Texas
    Posts
    17

    Unanswered: Determining whether data is an int or a float

    This is probably a dumb question with an easy solution, but I've thought and googled and scoured and come up with nothing that worked.

    I have to determine whether the result of an equation is an "integer" (as stated in the requirements) or not, i.e. if the answer is 1, 2, 10, etc. (is an integer) as opposed to 1.87 (not an integer).

    I'm not sure how to proceed; can someone point me in the right direction?

    Thanks.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    If you are using numeric or float datatypes, you can use the FLOOR() function to return just the integer portion of the result. Then you can use'
    Code:
    if (floor(@result) = @result)
      begin
        -- It's an integer
      end
    else
      begin
        -- it's a float
      end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •