Re:Ask HN: Have you ever migrated a large/old project to a d...
by andrewf on Wednesday September 14, 2022 @06:17AM
(#32835209)
I once ported a small amount of code from C to a managed language. The C code used single precision floats (24 bit significand), the target language supported only double precision (53 bit significand). There was little enough math that it was practical to do something like frob = x * 2 ** (53-24); x += frob; x -= frob; to truncate the extra bits and produce the same result, for easier verification.
The first thing I did before porting a feature was write a unit test on either side (because of course the Matlab side came with the most arbitrary test coverage you've ever seen). Then it was off to mexing Julia through the terrible C FFI in order to pretend to do validation. (In practice, this was not as helpful as it could have been, since I couldn't figure out how to make Julia and Matlab agree on a floating-point environment and Julia back then had some well-known correctness problems with its math library (that have been fixed by now, afaik)).
Other than that, the whole experience was pretty chaotic and terrible, would not advise doing again.