blackpenredpen

math for fun 

  1. Discussions
  2. Math Problems
  3. Is there a formula for Modulo or Fraction
Search
Abdelouahab Mamine
Nov 5, 2020

Is there a formula for Modulo or Fraction

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

4 comments
Abdelouahab Mamine
Nov 5, 2020

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


0
Abdelouahab Mamine
Nov 6, 2020

Another example , For integers

But I am looking for real numbers formula

0
Phinehas
Nov 24, 2020

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

Abdelouahab Mamine
Nov 26, 2020

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?

0