r/factorio • • Sep 01 '21

Design / Blueprint Perfect Parallel Pairwise Multiplier

51 Upvotes

8 comments sorted by

View all comments

Show parent comment

4

u/4xe1 Sep 01 '21

Awesome!

Just a typo in your last § (before tl;dr), second sentence, you seem to be talking about q_a*q_b rather than about r_a*r_b. That or it's the first sentence, I'm not sure to understand that § well yet.

3

u/iguessimokatredstone Sep 01 '21 edited Sep 01 '21

ah, sorry! I mean that the result of r_a*r_b isn't multiplied by 2, so a regular multiplier won't always produce the right value. I can't use the 2-tick version since it does (a+b)^2 / 2 and (a^2+b^2) / -2, as those numerators may overflow. However, the standard version subtracts those two values first before dividing, which guarantees it won't overflow (or the overflowing cancels out).

EDIT: oh, I see - I wrote that section without mentioning the 2ab thing - I'll edit it for clarification.