Feature SS-1245
7 votes

Automatic engineering unit prefixes like nm, km, etc.

Created by zapzapouch on 11/13/2014 8:19 PM Last Updated by crun on 2/11/2017 1:45 AM
%
 (hrs)
Logged: 0   (hrs)

 Description

For instance "10000 m=" should show "10 km", and then if you change it to "0.0001 m=" it should show "100 µm", without having to manually edit the "km" into "µm".  It should either be configurable per-field, or per-sheet?  Or maybe there can be a placeholder unit like "_m" or "?m" that means "automatically display using the best prefix".

    crun (Saturday, February 11, 2017 1:45 AM) #

Any comments on what the empirical rules for special units should be, or other special units, as I am adding this to my general format routines in javascript (below)

Currently handle seconds, kg, m, g specially.

 

//Suffix = unit name

function SpecialSuffix(number,suffix) { //deal with units that have special customary rules
var DoM = true; //DoMultipliers ie use multiplier prefixes
var UseTonnes = true;  //use Tonnes for 1000kg

switch (suffix) {

case "m": //metres -  only use multipliers up to km
if ( number >= 1e6 ) {  
DoM = false;
}
break;

case "s": //seconds - never
DoM = false;
break;

case "kg": //kg
if ( number<1 ) { //change to grams below 1kg
number = number / 1000;
suffix="g";
break;
}
if (( UseTonnes ) and ( number >=1e3 )) {  //Tonnes do have +multipliers (k,M,G etc
number = number/1000;
suffix = T;
break;
}
//else...
DoM = false; //never use multipliers > kg
break;


case "g": // grams
if ( number>=1e6 ) {
DoM=false;
}
} //switch
return {DoM,number,suffix};
}

    Frank Buss (Saturday, August 29, 2015 11:47 PM) #

At least for electronics it is clear: it should always be 1-3 digits before the decimal point (123 pF, 1.3 mA). For m, mm and km it can be the same, no need for a user table. This can be just a check-box: use 3 digits electronics rule or something like that. This is very important for electronics engineers.

Don't know what to do for cm and dm, anyone who uses dm? But might be useful to use cm instead of mm sometimes, so maybe a user table or other additional settings might be still useful.

    zapzapouch (Thursday, December 11, 2014 12:13 AM) #

"mkg" is a double prefix, which is not allowed.  gram is the unit, and if you enter "1000 g", it will write "1 kg".  If you write "1000000 g" it will output "1 Mg"

If you write "1000 seconds", it should return "1 ks", not "16.67 min".  Minutes are not an SI unit.  If you want minutes instead, you need to enter "min" in the desired units field.  If you want a time unit that automatically changes between minutes and hours, I think that should be a separate feature request.

    brotjob (Thursday, December 11, 2014 12:07 AM) #

"the best" is a vague thing. I think there is no algorithm to find the best unit. i.e. with kg, kg is the official unit. A simple algorithm would then define mkg for grams. Another example is with time. ms makes sense but ks?! time should default to min, hr, day, year etc not kilo mega etc.

So if we really want to implement this we need a table where you can enter which unit defaults to which prefix.

    Davide (Friday, November 14, 2014 9:29 PM) #

As civil engineer, the most used units are m, cm, mm, kg, tons, kN, MPa, kPa (depending on the context)

Leaving aside other features (SI vs imperial units) I think that if this is possible to implement, a possible range of choiches could be:

- base units (as it is now)

base 10 units (range 10^1)

base 1000 units (range 10^3)

 

This in a context menu, or maybe from global settings (could be better?).

    zapzapouch (Friday, November 14, 2014 5:42 PM) #

> just m, mm and km or also cm and dm?

in electrical engineering we only use the multiples of 1000, so no cm or dm, but I don't know about other fields.

    Davide (Friday, November 14, 2014 5:10 PM) #

I support this feature. Possibly with an option like the optimization.

    zapzapouch (Friday, November 14, 2014 4:15 PM) #

I mean that the unit should be chosen so that the number Is in the range 1.0 to 999.99.  It should include all SI prefixes from yocto- to yotta-.  In electronics we use everything from femptoamps to teraohms, for instance.

    Martin Kraska (Friday, November 14, 2014 4:00 PM) #

I support the proposal of a generic unit which stands for "most appropriate". The problem, however, remains: How to define "most appropriate"? What is the range of units to check against? just m, mm and km or also cm and dm? There might be a table of units acceptable to the user, among which SMath chooses if a generic unit is used. Also, it might be sensible to have the option to use this by default.

    zapzapouch (Thursday, November 13, 2014 8:21 PM) #

http://en.smath.info/forum/yaf_postst374_Engineering-format-for-displaying-results.aspx