Programmatically, while loop shift registers are identical to for loop shift registers. Refer to Section Shift Registers for the discussion. However, an example is provided to illustrate the use of shift registers in while loops.
In the following example, Euler's number e is computed to the specified accuracy using the infinite series
Notice that two shift registers keep track of the factorial and the sum. Also notice the dot in the multiplication. This is because the loop iteration is an integer 32 data type and the input from one of the shift registers is double precision numeric. The dot represents that the integer 32 data type has been coerced into a double precision number.
Save the program as e.vi. The result of running this program is shown in Computed e to 5 Digits.
- 1233 reads