Result Formatting - Control over number of significant digits

Result Formatting - Control over number of significant digits - BTS issue SS-21 and SS-22 - Messages

#1 Posted: 9/13/2012 10:22:23 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hi,

The results formatting of engineering computations should reflect their valid precision. Typically, this is assumed to be tree significant digits, perhaps 4 if the leading digit is 1. This is based on the precision of most available input data and in former times that was the achievable precision of the slide rule.

I find myself adjusting the number of digits in the right button menu on a case by case basis and have to correct the settings if Input data changes.

Currently, the only way to enforce a given relative precision independent of the result's order of magnitude is to set the exponential threshold to 1 and to specify the number of digits accordingly. However, the exponential threshold is better used to provide readablity than to control precision.

Very often I get results displayed as zero just because they are smaller than 0.01 and default precision set to 2 digits.

One can use brute force to set the relative precision by defining a function like

[MATH LANG=eng]format(x_,n_):line(oom:round(log10(x_)-0.5,0),round(x_/{10^oom},n_-1)*10^oom,2,1)[/MATH]

This yields

[MATH LANG=eng]format(1234563,2)=1200000[/MATH]

[MATH LANG=eng]format(0.00001234,2)=0.000012[/MATH]


Proposal:
  • Provide a control over the number of significant digits including cases like 1234556 -> 1230000.
  • Include an option to increase it by one if the first digit is 1. Setting "3" would then provide 1234000
  • Include a setting of the global default for the option to retain trailing zeros.
  • Provide control over corresponding default settings


My hope is that this might be useful for other users as well and that it is not too complex to implement.

Best regards, Martin Kraska
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Radovan Omorjan 7/28/2013 9:09:00 AM
#2 Posted: 7/28/2013 3:54:33 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

This proposal is not directly related to the previous one but fits in the topic name.

It is about creating formatted numbers for plot labels, i.e. formatted version of num2str. In the given code, there is just the option to specify decimal places after the delimiter and to specify the delimiter itself. One could easily explode the function into handling of significant digits, complex numbers with polar and rectangular shape, units and the conversion of matrices or lists (systems) in a single call. A nice place for such a function could be the custom funcions plugin, as there are already other string functions included.


Section String Processing.sm (43 KiB) downloaded 74 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Radovan Omorjan 7/28/2013 9:09:00 AM
  • New Posts New Posts
  • No New Posts No New Posts