Unexpected effects of setting locale

13 views
Skip to first unread message

Marcin Owsiany

unread,
Nov 28, 2022, 11:17:37 AM11/28/22
to Ledger
Hello,

I have encountered some surprising (to myself) effects of setting locale in a ledger-based Python program. I put up a minimal repro program and a somewhat extensive description of what I have found at https://github.com/porridge/ledger-issue-repro/tree/main/03-setting-locale-changes-precision

It would be great if someone could confirm my conjectures and answer some questions. I am pasting them below for convenience.

I did read the Journal File Format for Developers section of the documentation, but some things are still a mystery:

  1. Why does query() return a different set of postings depending on the locale, while .xact.posts() always returns three? I suspect this is because query() omits postings whose is_zero() returns True, while .xact.posts() always returns all postings?
  2. Why is the result of is_zero() on a value of 0.000346 locale-dependent? I suspect that the locale-specified precision somehow influences that decision. However I cannot see anything in the output of localeconv() that could cause precision to go so high (frac_digits is just 2).
  3. Why does the precision of the commodity price go as high as 18?
  4. What is the meaning of the value returned by truncated()? It seems to make no sense at all for all but one posting in the locale-enabled cases.

regards,
Marcin
Reply all
Reply to author
Forward
0 new messages