$\hphantom{bullet}$I've been looking at encryption and hashing and was wondering if there was a way to put bitwise operations into a more math based form. After a little research and a lot of thinking, I came up with the following formulas for AND, OR, and XOR. They are extremely lengthy as you can tell, and I'm certain there has to be a way to simplify these more. I couldn't find anything on adding, subtracting, or multiplying floors and I don't know how (or if it's possible) to turn the sums into integrals because they aren't Riemann sums. I'm asking for help simplifying or improving these formulas in (hopefully) a way that can be solved relatively easily by hand. In the functions, $n$ is the size of $a$ and $b$ in bits, and $a$ and $b$ are integers less than $2^n$. These functions are only meant to be used on positive integers (no decimals) and all addition/subtraction/multiplication/division should be calculated modulo $2^n$, with overflow.
$$f_{AND}(a,b)=\sum_{i\,=\,0}^{n-1}2^i \bigg(\bigg\lfloor\frac{a}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{a}{2^{i+1}}\bigg\rfloor\bigg) \bigg(\bigg\lfloor\frac{b}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{b}{2^{i+1}}\bigg\rfloor\bigg)$$
$$f_{OR}(a,b)=\sum_{i\,=\,0}^{n-1}2^i \Bigg(\bigg\lfloor\frac{a}{2^n}\bigg\rfloor-2\bigg\lfloor\frac{a}{2^{i+1}}\bigg\rfloor -\bigg(\bigg\lfloor\frac{a}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{a}{2^{i+1}}\bigg\rfloor\bigg) \bigg(\bigg\lfloor\frac{b}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{b}{2^{i+1}}\bigg\rfloor\bigg) +\bigg\lfloor\frac{b}{2^n}\bigg\rfloor-2\bigg\lfloor\frac{b}{2^{i+1}}\bigg\rfloor\Bigg)$$
$$f_{XOR}(a,b)=\sum_{i\,=\,0}^{n-1}2^i \Bigg(\bigg\lfloor\frac{a}{2^n}\bigg\rfloor-2\bigg\lfloor\frac{a}{2^{i+1}}\bigg\rfloor -2\bigg(\bigg\lfloor\frac{a}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{a}{2^{i+1}}\bigg\rfloor\bigg) \bigg(\bigg\lfloor\frac{b}{2^i}\bigg\rfloor-2\bigg\lfloor\frac{b}{2^{i+1}}\bigg\rfloor\bigg) +\bigg\lfloor\frac{b}{2^n}\bigg\rfloor-2\bigg\lfloor\frac{b}{2^{i+1}}\bigg\rfloor\Bigg)$$
$\hphantom{bullet}$My thought process for getting to the above end results begins here. I started by figuring out formulas where $a$ and $b$ were only one bit, 0 or 1. I found
$f_{and}(a,b)=ab$ $\hphantom{bullet}$ $f_{or}(a,b)=a-ab+b$ $\hphantom{bullet}$ $f_{xor}(a,b)=a-2ab+b$
$\hphantom{bullet}$To find the bit at any given binary index $i$ of a base 10 number $a$, $f_{bit}(a,i)=\frac{(a\mod{(2^{i+1})})-(a\mod{2^i})}{2^i}$
Avoiding the use of modulo, another StackExchange user said that $c\mod{d}=c-d\Big\lfloor\frac{c}{d}\Big\rfloor$,
so I substituted that into $f_{bit}$
$\frac{a-2^{i+1}\Big\lfloor\frac{a}{2^{i+1}}\Big\rfloor-\bigg(a-2^i\Big\lfloor\frac{a}{2^i}\Big\rfloor\bigg)}{2^i}\rightarrow\frac{a-a+2^i\Big\lfloor\frac{a}{2^i}\Big\rfloor-2^i2\Big\lfloor\frac{a}{i+1}\Big\rfloor}{2^i}\rightarrow\Big\lfloor\frac{a}{2^i}\Big\rfloor-2\Big\lfloor\frac{a}{2^{i+1}}\Big\rfloor$
$\hphantom{bullet}$Finally, I recognized to find the total of the bits at their indexes, I could use the sum from 0 to $n-1$ of each bitwise function multiplied by $2^i$, substituting the function above for $a$ and $b$, giving me the first three formulas in my post.
$\hphantom{bullet}$If there is a way to simplify this further, remove the floors and replace them with more basic operations, or turn the sums into integrals please let me know. I'm aware this is not practical/efficient to use in code, this is more of an experiment to see what can be done with mathematical functions for bitwise operators.