ctypes.sh
ctypes.sh copied to clipboard
Precision of float/double values during output
This is a wonderful library, am trying it now, and have noticed that double values are truncated at output to 6 digits.
A possible solution could be adding a printf format specifier in parens after the type argument:
-r double(.12f)
Would be awesome to be able to print exact hexadecimal contents of the returned value since most IEEE 754 to decimal string conversions will lose information.
Hmm, good idea. I'll try to prototype some code today.
I think writing it in hex is the correct solution, but doing it by default makes it harder to interact with the numbers in bash. What about having a rawdouble:/rawfloat: type for when you don't want to lose precision?
Fine by me, thanks!
Hm, not sure why Github didn't auto-tag this issue from b862cd0d1753cb0bcab35088b672a5ce3bf74c4b. It's related. Maybe sufficient for your needs? Did you have something else in mind, or are you aware of any way it is deficient? Thanks.
Thanks, looks good to me, I can imagine how someone wants to chain a bunch of libm operations without losing precision until the final operation...perfect.