|Significance arithmetic is a set of rules used in scientific calculations, and is used extensively in scientific application software. Specifically, significance arithmetic is used to determine the correct number of significant digits, or measured digits, in a calculation. The significant digits in a number are all its digits except for leading zeros that are two or more places to the left of the decimal point. For instance, 00.30, 0.00 and 0.60 each contain three significant digits, while 5 and 00 each only contain one significant digit.|
We need to compute the result of the addition of two numbers. The result must be rounded to n significant digits, where n is determined as follows:
First determine the number with the least number of digits to the right of the decimal point (this may be zero). Then the result will not contain any significant digits to the right of this digit, and all other digits are significant (except leading zeros that are two or more places to the left of the decimal point). For example, the result of 1.56 + 1236.1 will have only one significant digit immediately to the right of the decimal point, but all digits to the left of the decimal point will be significant.
There are several cases to consider when rounding a number to n significant digits:
1) If the number has less than n significant digits, the number is padded with trailing zeros. For example, 2.5 rounded to 3 significant digits is 2.50.
2) If the digit immediately to the right of the nth digit is greater than 5, the number is rounded up. For example, 2.56 rounded to 2 significant digits is 2.6.
3) If the digit immediately to the right of the nth digit is less than 5, the number is rounded down. For example, 2.54 rounded to 2 significant digits is 2.5.
4) If the digit immediately to the right of the nth digit is 5 and there are non-zero digits after the 5, the number is rounded up. For example, 2.551 rounded to 2 significant digits is 2.6.
5) If the digit immediately to the right of the nth digit is 5 and there are no subsequent non-zero digits, then the number is rounded whichever way leaves the nth digit even. For example, 2.55 rounded to 2 significant digits is 2.6, but 2.45 rounded to 2 significant digits is 2.4.
You will be given an expression as a String that will contain two numbers that are separated by a '+'. Each number will contain a non-empty integral part, as well as an optional fractional part which, if present, will be preceded by a decimal point. The numbers may contain leading zeros, and will always be positive. Examples of valid numbers are 0.456, 004.0, and 0. However, .025 is invalid because it has no integral part, and 45. is invalid because a fractional part must follow the decimal point.
Your result should be in the same format as described above. However, there should only be a leading zero if the integral part of the number is 0. For example, 0.00450 is a valid result, while 0459.2 is not.
|-||Numbers in expression may contain leading zeros.|
|-||expression will contain two numbers that are separated by a '+'.|
|-||Each number in expression will be a real number containing between 1 and 6 digits, inclusive (not including the decimal point).|
|-||Each number in expression will be formatted exactly as described in the problem statement.|