# Mathematical way of determining whether a number is an integer

I'm developing a computer program, and I've run into a mathematical problem. This isn't specific to any programming language, so it isn't really appropriate to ask on stackoverflow. Is there any way to determine whether a number is an integer using a mathematical function, from which a boolean response is given.

For example:

let x equal 159 let y equal 12.5

f(x) returns 1 and f(y) returns 0

Please get back to me if you can. If it isn't possible, is there a similar way to determine whether a number is odd or even?

EDIT:

I found a solution to the problem thats to Karolis Juodelė. I'll use a floor function to round the integer down, and then subtract the output from the original number. If the output is zero, then the function returns 0.

I just need to make sure that floor is a purely mathematical function. Does anyone know?

Thanks

-
I don't think this question belongs here. Such a function must take into consideration the machine representation of the number. For determining whether a given (integer) number n is even of odd, you may compute n - 2 * int(n/2); if n is even it returns 0, otherwise 1. –  mau Mar 24 '13 at 10:56
$-4$, really? I've seen way worse questions which haven't gotten a single downvote. –  Git Gud Mar 24 '13 at 11:00
@GitGud I gave an sympathy upvote, he said why he think that it belongs here, i only see 4 downvotes, no close vote. Guys tell him what he is doing wrong, he is new here how shall he know it ? –  Dominic Michaelis Mar 24 '13 at 11:01
@Jack what is a purely mathematical function for you ? –  Dominic Michaelis Mar 25 '13 at 6:13
Stackoverflow is for things like "practical, answerable problems that are unique to the programming profession" or "a specific programming problem"; your question is appropriate. In fact, with questions like this, you will almost always get better answers from programming sites than from math sites. –  Hurkyl Mar 25 '13 at 6:21
The most basic thing you could do is check if $x = \text{floor}(x)$. Here $\text{floor}$ returns the integer part of a number (rounds down). It is present in standard libraries of most languages.