Presentation is loading. Please wait.

Presentation is loading. Please wait.

Engineering Notation: Similar to scientific notation. Similar to scientific notation. Exponent is evenly divisible by 3 Exponent is evenly divisible by.

Similar presentations


Presentation on theme: "Engineering Notation: Similar to scientific notation. Similar to scientific notation. Exponent is evenly divisible by 3 Exponent is evenly divisible by."— Presentation transcript:

1 Engineering Notation: Similar to scientific notation. Similar to scientific notation. Exponent is evenly divisible by 3 Exponent is evenly divisible by 3 1 <= mantissa < 1000 1 <= mantissa < 1000 The x10 n portion is replaced by a “units prefix” The x10 n portion is replaced by a “units prefix”Examples: 3495V -> 3.495kV 3495V -> 3.495kV 0.00008763A -> 87.63uA 0.00008763A -> 87.63uA Engineering Output

2 int PutV_Eng(double v, int sigfigs, char *units) v : Value to be output sigfigs : number of sig figs to display units : string containing the units name to append. RETURNS: Number of characters printed. Engineering Output Function

3 SI Standard Prefixes ScalePrefixScalePrefix 10 3 kkilo 10 -3 mmilli 10 6 MMega 10 -6 umicro 10 9 GGiga 10 -9 nnano 10 12 TTera 10 -12 ppico 10 15 PPeta 10 -15 ffemto 10 18 EExa 10 -18 aatto 10 21 ZZetta 10 -21 zzepto 10 24 YYotta 10 -24 yyocto

4 Measure of the accuracy and/or precision of a value. Values are assumed known to +/- 0.5 sig fig. Values are assumed known to +/- 0.5 sig fig. Determines how many digits are reported. Determines how many digits are reported. By convention, a leading 1 is not considered significant. By convention, a leading 1 is not considered significant. By convention, trailing zeroes not considered significant. By convention, trailing zeroes not considered significant.Examples: 3.495kV has 4 sig figs. 3.495kV has 4 sig figs. 17.63uA has 3 sig figs. 17.63uA has 3 sig figs. 400m has 1 sig fig. (unless told otherwise). 400m has 1 sig fig. (unless told otherwise). Significant Figures

5 Round to nearest least significant digit. Visually, we look to see if the next digit is 5 or greater. Visually, we look to see if the next digit is 5 or greater. Our output algorithm automatically truncates (ignores) any digits to the right of the last digit output. Our output algorithm automatically truncates (ignores) any digits to the right of the last digit output. Algorithmically, we can simply add 0.5 sig fig and truncate. Algorithmically, we can simply add 0.5 sig fig and truncate.Examples: 4.53243 rounds to 4.532 with 4 sig. figs. 4.53243 rounds to 4.532 with 4 sig. figs. 4.53243 + 0.0005 = 4.532 | 93 (only output 4 digits) 4.53243 + 0.0005 = 4.532 | 93 (only output 4 digits) 2.38954 rounds to 2.39 with 3 sig figs. 2.38954 rounds to 2.39 with 3 sig figs. 2.38954 + 0.005 = 2.39 | 454 (only output 3 digits) 2.38954 + 0.005 = 2.39 | 454 (only output 3 digits) Rounding

6 In scientific notation, the value v can be expressed using a mantissa (m) and an exponent (e) as follows: v = m x 10 e This value is normalized if m has exactly one non-zero digit to the left of the decimal point, i.e, if: 1.0 <= m < 10.0 Ignoring significant of leading 1 (for now), 0.5 sig fig is then: hsf = 5 x 10 -N (hsf - “hemi-sig fig) If m has a leading 1, then hsf is another factor of ten smaller: hsf = 0.5 x 10 -N Rounding Normalized Values

7 1) TASK: Output negative sign and take absolute value. 2) TASK: Determine the mantissa and the exponent. 3) TASK: Add 0.5 Sig Fig to Mantissa 4) TASK: Scale mantissa so that exponent is divisible by 3. 5) TASK: Output mantissa to N sig figs. 6) TASK: Output prefix based on exponent. 7) TASK: Output units. 8) TASK: Return number of characters printed. Top Level Decomposition

8 v = -0.00001846774 to 4 sig figs 1) TASK: Output negative sign and take absolute value. OUTPUT: ‘-’ v = 0.00001846774 2) TASK: Determine the mantissa and the exponent. m = 1.846774 e = -5 3) TASK: Add 0.5 Sig Fig to Mantissa hsf = 5 x 10 -4 = 0.0005 hsf = hsf/10 = 0.00005 (since m < 2) m = m + hsf = 1.846774 + 0.00005 = 1.846824 Hand Example

9 4) TASK: Scale mantissa so that exponent is divisible by 3. e = -4 not divisible by 3. Multiply mantissa by 10 and decrement exponent until it is. m = 18.46824 e = -3 5) TASK: Output mantissa to N sig figs. Output m to (N+1 digits since leading digit was a 1) OUTPUT: 18.468 6) TASK: Output prefix based on exponent. OUTPUT: m 7) TASK: Output units. Hand Example (cont’d)

10 int PutV_Eng(double v, int sigfigs, char *units) { int i, c, e; double m, hsf; /* TASK 1 - Handle negative values */ if (n < 0.0) {PutC(‘-’); return 1 + PutV_Eng(-v, sigfigs, units); } PutV_Eng() Task 1

11 /* TASK 2 - Determine mantissa and exponent */ m = 0.0; e = 0; if (v != 0.0) { while (v >= 10.0) { v /= 10.0; e++;} while (v < 1.0) { v *= 10.0; e--;}} PutV_Eng() Task 2

12 /* TASK 3 - Add 0.5 sig fig */ hsf = (m < 2.0)? 0.5 : 5.0; for (i = 0; i < sigfigs; i++) hsf /= 10.0; PutV_Eng() Task 3

13 /* TASK 4 - Make exponent divisible by 3 */ while (e%3) { m *= 10.0; e--;} PutV_Eng() Task 4

14 /* TASK 5 - Output Mantissa */ c = PutV_lfN(m, sigfigs + ((m<2.0)? 1 : 0) ); /* The PutV_lfN() function is basically The PutV_lfN() function is basically the PutV_lf() function except that it the PutV_lf() function except that it only puts out N digits (followed by only puts out N digits (followed by trailing zeros if necessary). trailing zeros if necessary).*/ PutV_Eng() Task 5

15 /* TASK 6 - Output Prefix */ switch(e){ case -24: PutC(‘y’); c++; break; case -21: PutC(‘z’); c++; break; /*... */ case -3: PutC(‘m’); c++; break; case 0: break; case 3: PutC(‘k’); c++; break; /*... */ case 21: PutC(‘Z’); c++; break; case 24: PutC(‘Y’); c++; break; default: PutC(‘e’); c += 1 + PutV_i(e); } PutV_Eng() Task 6

16 /* TASK 7 - Output Units */ c += PutS(units); /* TASK 8 - Return number of characters */ return c; } PutV_Eng() Task 7 / 8


Download ppt "Engineering Notation: Similar to scientific notation. Similar to scientific notation. Exponent is evenly divisible by 3 Exponent is evenly divisible by."

Similar presentations


Ads by Google