mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 15:11:16 +08:00
Minor typo fix.
This commit is contained in:
parent
b1c36a85cf
commit
5c12f45ddc
@ -1,6 +1,6 @@
|
|||||||
import fullAdder from '../fullAdder';
|
import fullAdder from '../fullAdder';
|
||||||
|
|
||||||
describe('Full adder', () => {
|
describe('fullAdder', () => {
|
||||||
it('should add up two numbers', () => {
|
it('should add up two numbers', () => {
|
||||||
expect(fullAdder(0, 0)).toBe(0);
|
expect(fullAdder(0, 0)).toBe(0);
|
||||||
expect(fullAdder(2, 0)).toBe(2);
|
expect(fullAdder(2, 0)).toBe(2);
|
||||||
|
@ -3,7 +3,7 @@ import getBit from './getBit';
|
|||||||
/**
|
/**
|
||||||
* Add two numbers using only binary operators.
|
* Add two numbers using only binary operators.
|
||||||
*
|
*
|
||||||
* This is an implementation of full adders logic circut.
|
* This is an implementation of full adders logic circuit.
|
||||||
* https://en.wikipedia.org/wiki/Adder_(electronics)
|
* https://en.wikipedia.org/wiki/Adder_(electronics)
|
||||||
* Inspired by: https://www.youtube.com/watch?v=wvJc9CZcvBc
|
* Inspired by: https://www.youtube.com/watch?v=wvJc9CZcvBc
|
||||||
*
|
*
|
||||||
@ -65,5 +65,6 @@ export default function fullAdder(a, b) {
|
|||||||
// Set ith least significant bit of the result to bitSum.
|
// Set ith least significant bit of the result to bitSum.
|
||||||
result |= bitSum << i;
|
result |= bitSum << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user