I am working on a tool which generated a few thousand ASCII files (constraints), the contents of which include floating point numbers. I would like to run these constraints for comparison through an similar tool, which cannot handle floating point values with more than 20 decimal places. Testing manually indicates that simple truncation will suffice. So, how can I truncate all floating point values in a file (which are uniquely marked by a period) to no more than 20 decimal places?
Thanks,
Jon
I know for sure in Java and C (and almost certainly in other languages) there are ways to format strings. String.format() and printf() are some good examples. These can be used for case by doing something like:
I’ll find a website with better instructions in a second.
edit:
this should probably be a good enough link to get an idea:
http://www.cplusplus.com/reference/clibrary/cstdio/printf/
edit:
if you would like to use sed, a quick search makes it seem as though sed has a printf function too. the example I found is here:
http://docstore.mik.ua/orelly/unix/sedawk/ch07_09.htm