开发者

Comparison in Redundant binary representation RBR

开发者 https://www.devze.com 2022-12-29 09:30 出处:网络
How can I compare two numbers in the form of Redundant binary representation RBR ? Any Idea 开发者_如何学JAVA?This page has some information about RBR. This also includes a subtractor and a converter.

How can I compare two numbers in the form of Redundant binary representation RBR ? Any Idea 开发者_如何学JAVA?


This page has some information about RBR. This also includes a subtractor and a converter. What you do to find out, if two RBR numbers are equal is to subtract both numbers and then check, if the result matches one of the representations of zero.

Finding out, if a number is smaller than zero is a little bit harder: You have to find the first RBR digit (r_k and s_k in the article), which is not zero, starting from the most significant digit. If it is negative the result of the subtraction is negative. Otherwise the number is positive. So to sum it up, find the first pair that is either "00" or "11". If it is "00" the number is negative, positive otherwise.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号