-
Notifications
You must be signed in to change notification settings - Fork 0
NandGate
Jaime Redondo edited this page Jan 3, 2021
·
2 revisions
Class for the NAND gate.
-
BaseGate↳
NandGate
new NandGate(input: Input): NandGate| Name | Type | Default | Description |
|---|---|---|---|
input |
Input | none | The gate's input. |
NandGate - The gate object.
The gate's input.
Type: Input
The gate's output.
Type: Output
The gate's truth table.
Type: TruthTable
Create an instance of the gate.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
input |
Input | none | The gate's input. |
Returns
BaseGate - The gate object.
Get the gate's truth table for the specified number of inputs.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
inputs |
number | 2 | The number of inputs for the truth table. |
Returns
TruthTable - The truth table.
const { NandGate } = require("@jaimermxd/logic-gates");
var gate = NandGate.create([false, true]);
console.log(gate.input); // [ false, true ]
console.log(gate.output); // true
console.log(gate.truthTable);
/*
[
[ false, false, true ],
[ false, true, true ],
[ true, false, true ],
[ true, true, false ]
]
*/
var table = NandGate.getTruthTable(3);
console.log(table);
/*
[
[ false, false, false, true ],
[ false, false, true, true ],
[ false, true, false, true ],
[ false, true, true, true ],
[ true, false, false, true ],
[ true, false, true, true ],
[ true, true, false, true ],
[ true, true, true, false ]
]
*/