On 6/3/23 05:07, Tony Harminc wrote:
On Sun, 5 Mar 2023 at 08:32, David Crayford <[email protected]> wrote:
strfmon() should do the trick.
Sigh... Binary floating point for currencies. Doesn't end well. Even
Bitcoin et al expect correct decimal results.
Yep. C was never really used for writing business applications. As you
mentioned bitcoin I checked for golang decimal support as HyperLedger is
written in go. It's implemented using a library
https://pkg.go.dev/github.com/shopspring/decimal#section-readme that
looks similar to the Java BigDecimal class.
gcc and clang both support the N1312 draft of ISO/IEC WDTR24732 for
decimal floating point. However, the runtime I/O functions don't so you
need to use a library authored by IBM [1]. On platforms that don't
support decimal floating point in hardware it's implemented using
Cowlishaw's decNumber library.
[1] https://github.com/libdfp/libdfp
https://pubs.opengroup.org/onlinepubs/009604599/functions/strfmon.html
There seems to be a newer version at
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html
Still binary FP though.
Tony H.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN