How to seperate fractional and decimal part in a real number

I need formula for Modulo, or Fraction

I was wondering, is this even possible? I know there are lot's of solutions for this problem in computer science but is there a solution for this problem in arithmetics?

For example, if it is divisible by two, we can use: X mod 2 = (1+(-1)^(x-1))/2

please help me, or If it does not exist then tell me

Why am I looking for Formula for Modulo

Because (x mod 1) gives me the decimal part of a real number X, Or by using Fraction equation if it exists

Another example , For integers

But I am looking for real numbers formula

I'm not sure, but in terms of integer values for modulo 2 I have another way to do it.

x mod 2=1/2+cos(pi*x)/2

For even numbers: cos(pi*x)=1...so, 1/2+1/2=1

For odd numbers: cos(pi*x)=(-1)...so, 1/2+(-1/2)=0

Thank you very much Phinehas

I said in the first post: "How to seperate fractional and decimal part in a real number", So, Through your idea:

X=real number

For odd numbers: Decimal(X)=1-ACos(Cos(X*PI))/(PI)

For even numbers: Decimal(X)= ACos(Cos(X*PI))/(PI)

And :

Fraction=X-Decimal=Int(X)

Any idea for a general function?