
Ah, I see. 32 bit is certainly good enough. Speaking of assembler and platform specific stuff, do you know how to trap integer overflow events in C++ to handle them as exceptions? It would be a big performance advantage to try a calculation that might overflow, catch the overflow exception thrown by the event handler and then execute high precision/complex calculations instead to get the correct answer. This would need to coexist with code that doesn't catch overflow, so the event handler would need to inspect a dynamic policy that informs it whether to ignore or throw in it's currently context.
overflow_policy.push(THROW); try { a = b * c * d; } catch overthrow_exception { a = foo(b, c, d); }; overflow_policy.pop();
It's an interesting idea. I'm not an ASM expert, I just learned some for mp_int to play around a little. It could be done if the CPU was able to inspect the carry flag automatically after each arithmetic instruction and then issue an interrupt on overflow.
After looking at your mp_int data structure this sounds like something you could implement quite easily by reusing a large portion of your existing code.
Yes, that can be done. I don't know when it will happen. Maybe someone else will do it ;-) Kevin