lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
358 stars 51 forks source link

Add engineering output mode #31

Closed heitzmann closed 3 years ago

heitzmann commented 3 years ago

Similar to scientific mode, engineering mode also displays numbers in base 10 exponential notation, with the difference that exponents are always multiples of 3, to facilitate the interpretation in terms of SI prefixes.

The mode is activated in config thru "engineering" or "eng". For base and base2, it uses the special value 1000.

This PR is related to #29.

lcn2 commented 3 years ago

Thank you @heitzmann !!

This will be included in calc version 2.14.0.0 and beyond.

lcn2 commented 3 years ago

The pull request lacked regress test code, so we added code to test engineering mode (recession test mods to appear later). In doing so we discover a critical bug in the pull request where a call to base2(1000) would make calc unable and likely to dump core later on.

This bug was just patched on the master branch.

lcn2 commented 3 years ago

Top of master branch now contains both the base2(1000) fix and the improved regression tests for base() and base2().

heitzmann commented 3 years ago

I should have noticed that... Thanks for the fix and the PR merge!