Engineering and SI Number Format in Calc

ux.openoffice.org

Team

Explanation of Notations

The following is a short description of all the number formats to be discussed here.

Engineering Notation

This type of notation is an offshoot of Scientific Notation. The difference is that the exponent is only shown in multiples of 3. Thus a number such as 153,100 becomes 153.1E+3 in Engineering notation[1] instead of 1.531E+5 in scientific.

SI Notation

This is what's known as SI Prefix[2] notation. Similar to Engineering Notation the exponent also runs in multiples of 3 (usually), but the difference is that instead of showing the E+/- notation a symbol is given for each exponent. E.g. 153,100 in SI notation would be 153.1k.

Binary Prefix Notation

This is very similar to SI, but is intended for use when referring to sizes of data storage. Binary Prefix[3] Notation works in much a similar way, but is not calculated using 10 as a multiple (as with Scientific). Rather the closest matching power of 2 is used. Thus instead of 1000 we get 1024. As a convention similar symbols to SI is used, but with an "i" suffix to distinguish then. E.g. 153,100 in Binary Prefix Notation would become 149.51Ki.

Examples from other software

Example of how other software handle these formats.

Format Strings

Each number format requires a format string to indicate not just what type of format to use, but also details as per how many decimals to display. In all numeric notations the format string could indicate how many digits to display for the fraction portion of the number. E.g. 0.00+E0 would force a 2 decimal fraction if needed or not.

Engineering Notation

The Excel format string for engineering notation is similar to the scientific notation, except that it starts with 3 hashes (#). See the sample above. The current scientific notation in both Excel and OOo Calc is the same except for this point. Both use E+ to indicate exponent notation. The digit(s) after this indicate how many digits to use for the exponent. E.g. 0.0+E000 would force 3 digits for the exponent, if not needed it becomes padded with zeros. A further use of the Excel format string is that not only normal engineering notation is possible, but also notation in other multiples. E.g. ####E+0 would format 153,100 as 15.310E+4.

An alternative mentioned would be to substitute F for E instead. In this case ###.000E+00 would be equivalent to 0.000F+0.

SI Notation

There is (yet) no sample format string for this. Therefore we need to decide on one. A proposed idea would be to use a S to force SI notation. E.g. 0.00S. There's has one problem as the s is also used to denote seconds when formatting numbers as time units. So a different character should be used. Thus not one of the following already used: A, D, E, H, I, M, P, S, Y. A suggestion would be T stemming from the 1st non-used letter in the word meTric.

Binary Prefix Notation

Simple really, use B as for SI. It's not used in any other normal format.

Language Specific

Further to the above, it may be necessary to have language specific codes for these. More discussion is necessary.

Sample Implementations

File:EngSIFormula.ods contains custom formula to convert numbers to formatted text in the engineering-, SI- and binary notations. To use enable macros when opening as the formula are written in embedded sBasic.

File Format

TODO: how to persistently store the feature in various file formats.