I have faced this problem earlier but failed attempts with simple operations based on NumberForm, Round.. have forced me to stop looking for general solution. I have thought my skills in MMA were too low, but also today I am not able to do this in simple way. (haven't I learned anything? :))
This form of expression uncertainty in measurement is described by ISO check § 7.2.2. (link provided by OleksandrR.)
Assumptions
Since we are dealing with some kind of convention it is good to point assumptions to avoid future discussions (here and after x-measurement, dx-uncertainty):
dx is taken with 3 most significant digits and rounded to 2, while x is only taken with as many digits as dx imply without rounding.
- x > dx, or is at least the same order of magnitude as dx.
- x is given with maximum 15 digits. (so we do not use 1234567891234567 for example)
Function:
I can not supress the feelling that it is an overkill but I wanted to do this.
f[x_, dx_] := Module[{d1, d2, Rdx, Rx},
Rdx = {{#[[1]], Round[#[[2]] + .1 #[[3]] + .01]}~Join~
Table[0, {#2 - 2}], #2} & @@ RealDigits[dx, 10, 3];
Rx = Fold[#2 @@ #1 &,
RealDigits[x, 10, 15],
{
{#1[[1 ;; Max[#2, -Rdx[[2]] + 2 + #2]]], #2} &,
{Table[0, {-#2 + 1}]~Join~#1, If[#2 <= 0, 1 + Abs@#2, #2]} &
}
];
d1 = If[Length@#1 == #2, #1, Insert[#1, ".", #2 + 1]] & @@ Rx;
d2 = If[#2 == 1, Insert[#1, ".", 2], #1] & @@ Rdx;
Row[Join[d1, {"("}, d2, {")"}]]
]
Examples:
data = {{12345, 678}, {12345, 6.78}, {12345, .678}, {12345, .000678},
{123231231321321, 123.12312}};
data3 = {#1/100, #2} & @@@ data;
exp = f @@@ # & /@ {data, data3};
Grid[{{"{x,dx}", "expr.", "{x,dx}", "expr."}}~Join~Transpose@Riffle[{data, data3},exp],
Dividers -> {{3 -> True}, {2 -> True}}, Alignment -> {",", Left}]

Function destription: ( later...*)
Extension: If no one show much shorter solution I'll extend this a little bit. For example one could expect:
f[0.00001123,0.000001]
1.12(10) 10^(-5)
UncertainNumber[val, err]once upon a time), and write up formatting rules so that it displays asval(err)on the front end. That is, look up the usual formatting function/boxes. – J. M.'s missing motivation Jun 17 '13 at 00:33The real problem is to get the same number of digits on the right of comma.
We make: NumberForm[mu, 2] That sets proper format of mu. Now, we need to find how many digits is on the right of comma and set proper value formatting. – Zabaweb Jun 17 '13 at 12:37
NumberFormwill not help You at least not in such simple form, look atNumberForm[.4, 2] NumberForm[123, 2] NumberForm[.4, {2,2}] NumberForm[.042, {2,2}]. – Kuba Jun 17 '13 at 16:49