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.
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?
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?