TAILIEUCHUNG - Less-Numerical Algorithms part 4

Here is a piece of code for doing both G(i) and its inverse. unsigned long igray(unsigned long n, int is) For zero or positive values of is, return the Gray code of n; if is is negative, return the inverse Gray code of n. { int ish; unsigned long ans,idiv; if (is = 0) | 896 Chapter 20. Less-Numerical Algorithms exhausted. Here is a piece of code for doing both G i and its inverse. unsigned long igray unsigned long n int is For zero or positive values of is return the Gray code of n if is is negative return the inverse Gray code of n. int ish unsigned long ans idiv if is 0 This is the easy direction return n n 1 ish 1 This is the more complicated direction In hierarchical ans n stages starting with a one-bit right shift cause each for bit to be XORed with all more signibcant bits. ans idiv ans ish if idiv 1 ish 16 return ans ish 1 Double the amount of shift on the next cycle. In numerical work Gray codes can be useful when you need to do some task that depends intimately on the bits of i looping over many values of i. Then if there are economies in repeating the task for values differing by only one bit it makes sense to do things in Gray code order rather than consecutive order. We saw an example of this in for the generation of quasi-random sequences. CITED REFERENCES AND FURTHER READING Horowitz P. and Hill W. 1989 TheArtofElectronics 2nd ed. New York Cambridge University Press . Knuth . Combinatorial Algorithms vol. 4 of The Art of Computer Programming Reading MA Addison-Wesley . Unpublished. Will it be always so Cyclic Redundancy and Other Checksums When you send a sequence of bits from point A to point B you want to know that it will arrive without error. A common form of insurance is the parity bit attached to 7-bit ASCII characters to put them into 8-bit format. The parity bit is chosen so as to make the total number of one-bits versus zero-bits either always even even parity or always odd odd parity . Any single bit error in a character will thereby be detected. When errors are sufficiently rare and do not occur closely bunched in time use of parity provides sufficient error detection. Unfortunately in real situations a single noise event is likely to disrupt more than one bit. Since the parity bit has

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.