I have two files which are raw sequences of little-endian 32-bit floating-point values (with no crazy values like infinity, NaN, denormals etc.), and I want to produce their elementwise difference in a third file.
Now, I can write a small utility to do this with relative efficiently in pretty much any compiled language, but I was wondering if I could achieve the same more easily with a short script using common tools. My intuition says "no", since it's pretty "non-textual" work, but maybe I'm wrong.
A quick
perl
script that'll do it (Takes the two files as command line arguments, writes to standard output):The key here is
pack
andunpack
's"f<"
format to work with explicitly little-endian single precision floats (In the host systems' native format, normally IEEE754 on most typical hardware).