|
|
|
|
|
by bArray
2520 days ago
|
|
> it’s strictly limited to only being able to compute x/y when |x|>|y|. Anything else, you get garbage, including in the y=x I think it's literally just to keep the math circuit logic very simple, it'll be identical to MOD (just need to look at the remainder register) and |x| <= |y| will either require some hackery to convert it (with an appropriate test) or the machine having some idea of non-integer numbers. For implementation of division, you could have the circuit equivalence of: uint div(x, y){
uint t = x; //temporary (don't want to touch x)
uint c = 0; //counter
while(t >= y){
t = t - y;
c = c + 1;
}
return c; //remainder is in t
}
Not sure about the x == y case though.Of course there would be no checking, hence the garbage out when you misuse it. Your checking would be done manually. [1] https://en.wikipedia.org/wiki/Ones%27_complement |
|