I've got a pretty decent implementation of arbitrarily large integer arithmetic in the works, so I'm contemplating how I'll test it. For obvious reasons, the library needs to be absolutely correct in all possible cases. Thoroughly testing this presents a bit of a challenge: I can't use BYOND to independently verify any operations involving higher precision than BYOND's internal number format provides. If I remember correctly, I believe numbers are stored internally as 32-bit floats, which means the meaningful range of integers is probably something in the millions. I'm already running a bunch of tests with numbers in this range, and looking good.

For the rest of it, I've got a few ideas, and wondering if anyone else has any others.

- Write an external program in C using an existing, tested Big Number library (such as GNU MP) and verify each test against that. I'll probably end up doing this, though it could be a pain.

- Test calculations that can be easily verified by hand. Not too hard, but I can't use this method to run, say, 5 million randomly generated tests.

- Test a series of operations that is guaranteed to end up with one of the original numbers involved as the final result; then compare that with the original number in question. For example, 5 + 23 - 23 should be 5. Easily testable for arbitrary numbers, but it only tests a small subset of combinations and could be vulnerable to bugs that happen to work by coincidence in these special cases.

Any thoughts?

Copyright © 2015 BYOND.
All rights reserved.

This sounds promising, and might not be that much of a pain (at least for someone well-conversant with C, as I presume you are). Just let BYOND generate random strings of digits and operators, and output them to a test file:

5

+

3

8

*

2

16

^

2

256

/

128

2

...except using much bigger numbers, of course!

I imagine a file format like this would be pretty trivial to load in C.