Add configurable decimal separator and fixed decimal places - #3
Add configurable decimal separator and fixed decimal places#3sheep-farm wants to merge 2 commits into
Conversation
Reads two optional display preferences from ~/.config/Omacom/omacalc.conf: - decimalSeparator (dot/comma) lets numbers be typed and shown with a Brazilian-style comma instead of a period. Internal parsing and math stay locale-independent; only the presented digits and the decimal key label change. - fixedDecimalPlaces rounds non-integer results to a fixed number of decimals (e.g. 10 / 3 -> 3.33), while whole-number results keep showing as plain integers. Left unset, formatting is unchanged. Chained operands and expressions reflect the same rounding as the result they came from, instead of leaking full floating-point precision.
With decimalSeparator=comma the display, and so the clipboard, uses a comma: copying 1.5 puts "1,500" on the clipboard when it was typed as 1.500. QLocale::c() accepts a comma as a thousands group when three digits follow it, so that parsed cleanly as 1500 and the existing comma-to-dot fallback never ran. Copying a number out of the calculator and pasting it back multiplied it by a thousand. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Reviewed this against master and ran One defect, which I have pushed as 90e8c98. Three things I did not touch, because they are calls for the maintainer rather than bugs to patch under you.
In the tests, the Worth knowing: PR #7 already contains this commit, so the two cannot be merged independently. |
Summary
~/.config/Omacom/omacalc.conf:decimalSeparator(dotorcomma) lets numbers be typed and displayed with a Brazilian-style comma instead of a period. All internal parsing and math stay locale-independent; only the presented digits and the decimal key label change.fixedDecimalPlacesrounds non-integer results to a fixed number of decimal places (e.g.10 ÷ 3becomes3.33withfixedDecimalPlaces=2), while whole-number results (4 + 6) keep showing as plain integers. Left unset, formatting is unchanged.3.33 + 1, not3.33333333333333 + 1).Test plan
./bin/testpasses./bin/buildsucceeds