r/TuringComplete • • 19d ago

How to do modulo

Post image
9 Upvotes

11 comments sorted by

View all comments

Show parent comment

2

u/Pretty-Potential4733 19d ago

I have a really fast DIV.

7

u/Crispy1961 19d ago

Did you build a DIV that does not also compute the remainder?

Most implementations I have seen do that. The remainder is the modulo. You should be able to copy paste your DIV implementation and just connect the remainder to the output.

Btw, never use NEG component to subtract. Use NOT and then connect "ON" to carry in of your ADD component.

1

u/Pretty-Potential4733 12d ago

whatever

2

u/Crispy1961 12d ago

Whatever? Am I bothering you by trying to help? Sorry.

1

u/Fastpast93 12d ago

He didn't ask for help. He was showing an easy method to do modulo.

1

u/Crispy1961 12d ago

And I improved upon it. The easiest way to do modulo is to copy paste your sub solution.

If for some reason the dub doesn't compute mod, then this is a nice approach, but the NEG is unnecessary. Using NOT and carry-in of adder to subtract is a nifty little trick.

Are we not here to share and learn together?

1

u/Fastpast93 12d ago

It's very good you helped, I just wouldn't be offended if the person discarded it.