Skip to content

Add --decimals option to the convert command - #160

Merged
codepiyusss merged 1 commit into
codepiyusss:mainfrom
jay23606:pr-go/77-improve-add-decimals-option-to-the-conve
Nov 21, 2026
Merged

codepiyusss merged 1 commit into
codepiyusss:mainfrom
jay23606:pr-go/77-improve-add-decimals-option-to-the-conve

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

Closes #77

What

Adds a --decimals option (type int, default 2) to fixit convert. The result is printed as round(result, decimals).

Why

fixit convert 100 f2c printed 37.77777777777778 with no way to control rounding.

Changes

  • fixit/cli.py: new --decimals argument on the convert subparser; run_convert prints round(result, args.decimals).
  • tests/test_cli.py: tests for the default (37.78), --decimals 4 (37.7778), and a whole result keeping its trailing zero (212.0 for 100 c2f).

Note: the default output of f2c changes from full precision to two decimals, as the issue asks.

Testing

  • python -m pytest tests/test_cli.py -k convert -q: 5 passed
  • python -m pytest -q: 127 passed

Regression test: untested: a small feature has no test that fails before the change

Fixes #77

@codepiyusss
codepiyusss merged commit 1e9cdb4 into codepiyusss:main Nov 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve: add --decimals option to the convert command

2 participants