Misplaced Pages

Subtractor

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

In electronics , a subtractor – a digital circuit that performs subtraction of numbers – can be designed using the same approach as that of an adder . The binary subtraction process is summarized below. As with an adder, in the general case of calculations on multi-bit numbers, three bits are involved in performing the subtraction for each bit of the difference : the minuend ( X i {\displaystyle X_{i}} ), subtrahend ( Y i {\displaystyle Y_{i}} ), and a borrow in from the previous (less significant) bit order position ( B i {\displaystyle B_{i}} ). The outputs are the difference bit ( D i {\displaystyle D_{i}} ) and borrow bit B i + 1 {\displaystyle B_{i+1}} . The subtractor is best understood by considering that the subtrahend and both borrow bits have negative weights, whereas the X and D bits are positive. The operation performed by the subtractor is to rewrite X i − Y i − B i {\displaystyle X_{i}-Y_{i}-B_{i}} (which can take the values -2, -1, 0, or 1) as the sum − 2 B i + 1 + D i {\displaystyle -2B_{i+1}+D_{i}} .

#737262

51-450: Where ⊕ represents exclusive or . Subtractors are usually implemented within a binary adder for only a small cost when using the standard two's complement notation, by providing an addition/subtraction selector to the carry-in and to invert the second operand. The half subtractors can be designed through the combinational Boolean logic circuits as shown in Figure 1 and 2.The half subtractor

102-635: A binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a property of arithmetic, e.g. "3 + 4 = 4 + 3" or "2 × 5 = 5 × 2" , the property can also be used in more advanced settings. The name is needed because there are operations, such as division and subtraction , that do not have it (for example, "3 − 5 ≠ 5 − 3" ); such operations are not commutative, and so are referred to as noncommutative operations . The idea that simple operations, such as

153-641: A set S is called commutative if x ∗ y = y ∗ x for all  x , y ∈ S . {\displaystyle x*y=y*x\qquad {\mbox{for all }}x,y\in S.} In other words, an operation is commutative if every two elements commute. An operation that does not satisfy the above property is called noncommutative . One says that x commutes with y or that x and y commute under ∗ {\displaystyle *} if x ∗ y = y ∗ x . {\displaystyle x*y=y*x.} That is,

204-1029: A vector space to itself (see below for the Matrix representation). Matrix multiplication of square matrices is almost always noncommutative, for example: [ 0 2 0 1 ] = [ 1 1 0 1 ] [ 0 1 0 1 ] ≠ [ 0 1 0 1 ] [ 1 1 0 1 ] = [ 0 1 0 1 ] {\displaystyle {\begin{bmatrix}0&2\\0&1\end{bmatrix}}={\begin{bmatrix}1&1\\0&1\end{bmatrix}}{\begin{bmatrix}0&1\\0&1\end{bmatrix}}\neq {\begin{bmatrix}0&1\\0&1\end{bmatrix}}{\begin{bmatrix}1&1\\0&1\end{bmatrix}}={\begin{bmatrix}0&1\\0&1\end{bmatrix}}} The vector product (or cross product ) of two vectors in three dimensions

255-517: A borrow out needs to be generated when X < Y + B in {\displaystyle X<Y+B_{\text{in}}} . When a borrow out is generated, 2 is added in the current digit. (This is similar to the subtraction algorithm in decimal. Instead of adding 2, we add 10 when we borrow.) Therefore, D = X − Y − B in + 2 B out {\displaystyle D=X-Y-B_{\text{in}}+2B_{\text{out}}} . The truth table for

306-473: A negate gate is: where lines to the right are outputs and others (from the top, bottom or left) are inputs. The full subtractor is a combinational circuit which is used to perform subtraction of three input bits : the minuend X {\displaystyle X} , subtrahend Y {\displaystyle Y} , and borrow in B in {\displaystyle B_{\text{in}}} . The full subtractor generates two output bits:

357-468: A random bit XORed with a non-random bit will result in a random bit. Multiple sources of potentially random data can be combined using XOR, and the unpredictability of the output is guaranteed to be at least as good as the best individual source. XOR is used in RAID 3–6 for creating parity information. For example, RAID can "back up" bytes 10011100 2 and 01101100 2 from two (or more) hard drives by XORing

408-486: A simple adder can be made with an XOR gate to add the numbers, and a series of AND, OR and NOT gates to create the carry output. On some computer architectures, it is more efficient to store a zero in a register by XOR-ing the register with itself (bits XOR-ed with themselves are always zero) than to load and store the value zero. In cryptography , XOR is sometimes used as a simple, self-inverse mixing function, such as in one-time pad or Feistel network systems. XOR

459-411: A specific pair of elements may commute even if the operation is (strictly) noncommutative. Division is noncommutative, since 1 ÷ 2 ≠ 2 ÷ 1 {\displaystyle 1\div 2\neq 2\div 1} . Subtraction is noncommutative, since 0 − 1 ≠ 1 − 0 {\displaystyle 0-1\neq 1-0} . However it

510-470: A theory of functions. Today the commutative property is a well-known and basic property used in most branches of mathematics. The first recorded use of the term commutative was in a memoir by François Servois in 1814, which used the word commutatives when describing functions that have what is now called the commutative property. Commutative is the feminine form of the French adjective commutatif , which

561-471: Is anti-commutative ; i.e., b × a = −( a × b ). Records of the implicit use of the commutative property go back to ancient times. The Egyptians used the commutative property of multiplication to simplify computing products . Euclid is known to have assumed the commutative property of multiplication in his book Elements . Formal uses of the commutative property arose in the late 18th and early 19th centuries, when mathematicians began to work on

SECTION 10

#1733085008738

612-409: Is a combinational circuit which is used to perform subtraction of two bits. It has two inputs, the minuend X {\displaystyle X} and subtrahend Y {\displaystyle Y} and two outputs the difference D {\displaystyle D} and borrow out B out {\displaystyle B_{\text{out}}} . The borrow out signal

663-557: Is a group . This unfortunately prevents the combination of these two systems into larger structures, such as a mathematical ring . However, the system using exclusive or ( { T , F } , ⊕ ) {\displaystyle (\{T,F\},\oplus )} is an abelian group . The combination of operators ∧ {\displaystyle \wedge } and ⊕ {\displaystyle \oplus } over elements { T , F } {\displaystyle \{T,F\}} produce

714-429: Is a logical operator whose negation is the logical biconditional . With two inputs, XOR is true if and only if the inputs differ (one is true, one is false). With multiple inputs, XOR is true if and only if the number of true inputs is odd . It gains the name "exclusive or" because the meaning of "or" is ambiguous when both operands are true. XOR excludes that case. Some informal ways of describing XOR are "one or

765-451: Is a metalogical symbol representing "can be replaced in a proof with". Commutativity is a property of some logical connectives of truth functional propositional logic . The following logical equivalences demonstrate that commutativity is a property of particular connectives. The following are truth-functional tautologies . In group and set theory , many algebraic structures are called commutative when certain operands satisfy

816-528: Is also called "not left-right arrow" ( \nleftrightarrow ) in LaTeX -based markdown ( ↮ {\displaystyle \nleftrightarrow } ). Apart from the ASCII codes, the operator is encoded at U+22BB ⊻ XOR ( &veebar; ) and U+2295 ⊕ CIRCLED PLUS ( &CirclePlus;, &oplus; ), both in block mathematical operators . Commutative In mathematics ,

867-557: Is also found in other languages. However, many languages have disjunctive constructions which are robustly exclusive such as French soit... soit . The symbol used for exclusive disjunction varies from one field of application to the next, and even depends on the properties being emphasized in a given context of discussion. In addition to the abbreviation "XOR", any of the following symbols may also be seen: If using binary values for true (1) and false (0), then exclusive or works exactly like addition modulo 2. Exclusive disjunction

918-494: Is also heavily used in block ciphers such as AES (Rijndael) or Serpent and in block cipher implementation (CBC, CFB, OFB or CTR). In simple threshold-activated artificial neural networks , modeling the XOR function requires a second layer because XOR is not a linearly separable function. Similarly, XOR can be used in generating entropy pools for hardware random number generators . The XOR operation preserves randomness, meaning that

969-478: Is always associative but not always commutative. Some forms of symmetry can be directly linked to commutativity. When a commutative operation is written as a binary function z = f ( x , y ) , {\displaystyle z=f(x,y),} then this function is called a symmetric function , and its graph in three-dimensional space is symmetric across the plane y = x {\displaystyle y=x} . For example, if

1020-432: Is calculated using an XOR gate which is commutative. The truth table for the half subtractor is: Using the table above and a Karnaugh map , we find the following logic equations for D {\displaystyle D} and B out {\displaystyle B_{\text{out}}} : Consequently, a simplified half-subtract circuit, advantageously avoiding crossed traces in particular as well as

1071-478: Is called the function's algebraic normal form . Disjunction is often understood exclusively in natural languages . In English, the disjunctive word "or" is often understood exclusively, particularly when used with the particle "either". The English example below would normally be understood in conversation as implying that Mary is not both a singer and a poet. However, disjunction can also be understood inclusively, even in combination with "either". For instance,

SECTION 20

#1733085008738

1122-417: Is classified more precisely as anti-commutative , since 0 − 1 = − ( 1 − 0 ) {\displaystyle 0-1=-(1-0)} . Exponentiation is noncommutative, since 2 3 ≠ 3 2 {\displaystyle 2^{3}\neq 3^{2}} . This property leads to two different "inverse" operations of exponentiation (namely,

1173-1197: Is derived from the French noun commutation and the French verb commuter , meaning "to exchange" or "to switch", a cognate of to commute . The term then appeared in English in 1838. in Duncan Gregory 's article entitled "On the real nature of symbolical algebra" published in 1840 in the Transactions of the Royal Society of Edinburgh . In truth-functional propositional logic, commutation , or commutativity refer to two valid rules of replacement . The rules allow one to transpose propositional variables within logical expressions in logical proofs . The rules are: ( P ∨ Q ) ⇔ ( Q ∨ P ) {\displaystyle (P\lor Q)\Leftrightarrow (Q\lor P)} and ( P ∧ Q ) ⇔ ( Q ∧ P ) {\displaystyle (P\land Q)\Leftrightarrow (Q\land P)} where " ⇔ {\displaystyle \Leftrightarrow } "

1224-550: Is equivalent to the disjunction of the negation of its antecedent and its consequence) and material equivalence . In summary, we have, in mathematical and in engineering notation: By applying the spirit of De Morgan's laws , we get: ¬ ( p ↮ q ) ⇔ ¬ p ↮ q ⇔ p ↮ ¬ q . {\displaystyle \lnot (p\nleftrightarrow q)\Leftrightarrow \lnot p\nleftrightarrow q\Leftrightarrow p\nleftrightarrow \lnot q.} Although

1275-469: Is often used for bitwise operations. Examples: As noted above, since exclusive disjunction is identical to addition modulo 2, the bitwise exclusive disjunction of two n -bit strings is identical to the standard vector of addition in the vector space ( Z / 2 Z ) n {\displaystyle (\mathbb {Z} /2\mathbb {Z} )^{n}} . In computer science, exclusive disjunction has several uses: In logical circuits,

1326-627: Is set when the subtractor needs to borrow from the next digit in a multi-digit subtraction. That is, B out = 1 {\displaystyle B_{\text{out}}=1} when X < Y {\displaystyle X<Y} . Since X {\displaystyle X} and Y {\displaystyle Y} are bits, B out = 1 {\displaystyle B_{\text{out}}=1} if and only if X = 0 {\displaystyle X=0} and Y = 1 {\displaystyle Y=1} . An important point worth mentioning

1377-398: Is sometimes useful to write p ↮ q {\displaystyle p\nleftrightarrow q} in the following way: or: This equivalence can be established by applying De Morgan's laws twice to the fourth line of the above proof. The exclusive or is also equivalent to the negation of a logical biconditional , by the rules of material implication (a material conditional

1428-450: Is that the half subtractor diagram aside implements X − Y {\displaystyle X-Y} and not Y − X {\displaystyle Y-X} since B out {\displaystyle B_{\text{out}}} on the diagram is given by This is an important distinction to make since subtraction itself is not commutative , but the difference bit D {\displaystyle D}

1479-782: Is the function f ( x , y ) = x + y 2 , {\displaystyle f(x,y)={\frac {x+y}{2}},} which is clearly commutative (interchanging x and y does not affect the result), but it is not associative (since, for example, f ( − 4 , f ( 0 , + 4 ) ) = − 1 {\displaystyle f(-4,f(0,+4))=-1} but f ( f ( − 4 , 0 ) , + 4 ) = + 1 {\displaystyle f(f(-4,0),+4)=+1} ). More such examples may be found in commutative non-associative magmas . Furthermore, associativity does not imply commutativity either – for example multiplication of quaternions or of matrices

1530-419: The n th-root operation and the logarithm operation), whereas multiplication only has one inverse operation. Some truth functions are noncommutative, since the truth tables for the functions are different when one changes the order of the operands. For example, the truth tables for (A ⇒ B) = (¬A ∨ B) and (B ⇒ A) = (A ∨ ¬B) are Function composition of linear functions from the real numbers to

1581-423: The logical conjunction ("logical and", ∧ {\displaystyle \wedge } ), the disjunction ("logical or", ∨ {\displaystyle \lor } ), and the negation ( ¬ {\displaystyle \lnot } ) as follows: The exclusive disjunction p ↮ q {\displaystyle p\nleftrightarrow q} can also be expressed in

Subtractor - Misplaced Pages Continue

1632-557: The multiplication and addition of numbers, are commutative was for many years implicitly assumed. Thus, this property was not named until the 19th century, when mathematics started to become formalized. A similar property exists for binary relations ; a binary relation is said to be symmetric if the relation applies regardless of the order of its operands; for example, equality is symmetric as two equal mathematical objects are equal regardless of their order. A binary operation ∗ {\displaystyle *} on

1683-529: The operators ∧ {\displaystyle \wedge } ( conjunction ) and ∨ {\displaystyle \lor } ( disjunction ) are very useful in logic systems, they fail a more generalizable structure in the following way: The systems ( { T , F } , ∧ ) {\displaystyle (\{T,F\},\wedge )} and ( { T , F } , ∨ ) {\displaystyle (\{T,F\},\lor )} are monoids , but neither

1734-680: The uncertainty principle of Heisenberg , if the two operators representing a pair of variables do not commute, then that pair of variables are mutually complementary , which means they cannot be simultaneously measured or known precisely. For example, the position and the linear momentum in the x {\displaystyle x} -direction of a particle are represented by the operators x {\displaystyle x} and − i ℏ ∂ ∂ x {\displaystyle -i\hbar {\frac {\partial }{\partial x}}} , respectively (where ℏ {\displaystyle \hbar }

1785-532: The above have motivated analyses of the exclusivity inference as pragmatic conversational implicatures calculated on the basis of an inclusive semantics . Implicatures are typically cancellable and do not arise in downward entailing contexts if their calculation depends on the Maxim of Quantity . However, some researchers have treated exclusivity as a bona fide semantic entailment and proposed nonclassical logics which would validate it. This behavior of English "or"

1836-422: The commutative property. In higher branches of mathematics, such as analysis and linear algebra the commutativity of well-known operations (such as addition and multiplication on real and complex numbers) is often used (or implicitly assumed) in proofs. The associative property is closely related to the commutative property. The associative property of an expression containing two or more occurrences of

1887-476: The difference D {\displaystyle D} and borrow out B out {\displaystyle B_{\text{out}}} . B in {\displaystyle B_{\text{in}}} is set when the previous digit is borrowed from X {\displaystyle X} . Thus, B in {\displaystyle B_{\text{in}}} is also subtracted from X {\displaystyle X} as well as

1938-865: The effect of their compositions x d d x {\textstyle x{\frac {d}{dx}}} and d d x x {\textstyle {\frac {d}{dx}}x} (also called products of operators) on a one-dimensional wave function ψ ( x ) {\displaystyle \psi (x)} : x ⋅ d d x ψ = x ⋅ ψ ′   ≠   ψ + x ⋅ ψ ′ = d d x ( x ⋅ ψ ) {\displaystyle x\cdot {\mathrm {d} \over \mathrm {d} x}\psi =x\cdot \psi '\ \neq \ \psi +x\cdot \psi '={\mathrm {d} \over \mathrm {d} x}\left(x\cdot \psi \right)} According to

1989-406: The first example below shows that "either" can be felicitously used in combination with an outright statement that both disjuncts are true. The second example shows that the exclusive inference vanishes away under downward entailing contexts. If disjunction were understood as exclusive in this example, it would leave open the possibility that some people ate both rice and beans. Examples such as

2040-399: The following way: This representation of XOR may be found useful when constructing a circuit or network, because it has only one ¬ {\displaystyle \lnot } operation and small number of ∧ {\displaystyle \land } and ∨ {\displaystyle \lor } operations. A proof of this identity is given below: It

2091-573: The full subtractor is: Therefore the equation is: D = X ⊕ Y ⊕ B i n {\displaystyle D=X\oplus Y\oplus B_{in}} B o u t = X ¯ B i n + X ¯ Y + Y B i n {\displaystyle B_{out}={\bar {X}}B_{in}+{\bar {X}}Y+YB_{in}} Exclusive or Exclusive or , exclusive disjunction , exclusive alternation , logical non-equivalence , or logical inequality

Subtractor - Misplaced Pages Continue

2142-826: The function f is defined as f ( x , y ) = x + y {\displaystyle f(x,y)=x+y} then f {\displaystyle f} is a symmetric function. For relations, a symmetric relation is analogous to a commutative operation, in that if a relation R is symmetric, then a R b ⇔ b R a {\displaystyle aRb\Leftrightarrow bRa} . In quantum mechanics as formulated by Schrödinger , physical variables are represented by linear operators such as x {\displaystyle x} (meaning multiply by x {\displaystyle x} ), and d d x {\textstyle {\frac {d}{dx}}} . These two operators do not commute as may be seen by considering

2193-596: The inputs differ: Exclusive disjunction essentially means 'either one, but not both nor none'. In other words, the statement is true if and only if one is true and the other is false. For example, if two horses are racing, then one of the two will win the race, but not both of them. The exclusive disjunction p ↮ q {\displaystyle p\nleftrightarrow q} , also denoted by p ? ⁡ q {\displaystyle p\operatorname {?} q} or J p q {\displaystyle Jpq} , can be expressed in terms of

2244-406: The just mentioned bytes, resulting in ( 11110000 2 ) and writing it to another drive. Under this method, if any one of the three hard drives are lost, the lost byte can be re-created by XORing bytes from the remaining drives. For instance, if the drive containing 01101100 2 is lost, 10011100 2 and 11110000 2 can be XORed to recover the lost byte. XOR is also used to detect an overflow in

2295-404: The logical "AND" operation as multiplication on F 2 {\displaystyle \mathbb {F} _{2}} and the "XOR" operation as addition on F 2 {\displaystyle \mathbb {F} _{2}} : The description of a Boolean function as a polynomial in F 2 {\displaystyle \mathbb {F} _{2}} , using this basis,

2346-961: The other but not both", "either one or the other", and "A or B, but not A and B". It is symbolized by the prefix operator J {\displaystyle J} and by the infix operators XOR ( / ˌ ɛ k s ˈ ɔː r / , / ˌ ɛ k s ˈ ɔː / , / ˈ k s ɔː r / or / ˈ k s ɔː / ), EOR , EXOR , ∨ ˙ {\displaystyle {\dot {\vee }}} , ∨ ¯ {\displaystyle {\overline {\vee }}} , ∨ _ {\displaystyle {\underline {\vee }}} , ⩛ , ⊕ {\displaystyle \oplus } , ↮ {\displaystyle \nleftrightarrow } , and ≢ {\displaystyle \not \equiv } . The truth table of A ⊕ B {\displaystyle A\oplus B} shows that it outputs true whenever

2397-828: The real numbers is almost always noncommutative. For example, let f ( x ) = 2 x + 1 {\displaystyle f(x)=2x+1} and g ( x ) = 3 x + 7 {\displaystyle g(x)=3x+7} . Then ( f ∘ g ) ( x ) = f ( g ( x ) ) = 2 ( 3 x + 7 ) + 1 = 6 x + 15 {\displaystyle (f\circ g)(x)=f(g(x))=2(3x+7)+1=6x+15} and ( g ∘ f ) ( x ) = g ( f ( x ) ) = 3 ( 2 x + 1 ) + 7 = 6 x + 10 {\displaystyle (g\circ f)(x)=g(f(x))=3(2x+1)+7=6x+10} This also applies more generally for linear and affine transformations from

2448-774: The result of a signed binary arithmetic operation. If the leftmost retained bit of the result is not the same as the infinite number of digits to the left, then that means overflow occurred. XORing those two bits will give a "1" if there is an overflow. XOR can be used to swap two numeric variables in computers, using the XOR swap algorithm ; however this is regarded as more of a curiosity and not encouraged in practice. XOR linked lists leverage XOR properties in order to save space to represent doubly linked list data structures. In computer graphics , XOR-based drawing methods are often used to manage such items as bounding boxes and cursors on systems without alpha channels or overlay planes. It

2499-401: The same operator states that the order operations are performed in does not affect the final result, as long as the order of terms does not change. In contrast, the commutative property states that the order of the terms does not affect the final result. Most commutative operations encountered in practice are also associative. However, commutativity does not imply associativity. A counterexample

2550-502: The subtrahend Y {\displaystyle Y} . Or in symbols: X − Y − B in {\displaystyle X-Y-B_{\text{in}}} . Like the half subtractor, the full subtractor generates a borrow out when it needs to borrow from the next digit. Since we are subtracting Y {\displaystyle Y} and B in {\displaystyle B_{\text{in}}} from X {\displaystyle X} ,

2601-520: The well-known two-element field F 2 {\displaystyle \mathbb {F} _{2}} . This field can represent any logic obtainable with the system ( ∧ , ∨ ) {\displaystyle (\land ,\lor )} and has the added benefit of the arsenal of algebraic analysis tools for fields. More specifically, if one associates F {\displaystyle F} with 0 and T {\displaystyle T} with 1, one can interpret

SECTION 50

#1733085008738
#737262