You are here

Shift Registers

26 July, 2019 - 09:47
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/5b6e61df-b830-48cb-9764-94696cb47c80@1.3

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.

media/image38.png
Figure 5.38 While Loop Shift Registers 

In the following example, Euler's number e is computed to the specified accuracy using the infinite series

media/image39.png

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.

media/image40.png
Figure 5.39 Computing e  

Save the program as e.vi. The result of running this program is shown in Computed e to 5 Digits.

media/image41.png
Figure 5.40 Computed e to 5 Digits