-
Notifications
You must be signed in to change notification settings - Fork 0
NotGate
Jaime Redondo edited this page Jan 3, 2021
·
2 revisions
Class for the NOT gate.
-
BaseGate↳
NotGate
new NotGate(input: Input): NotGate| Name | Type | Default | Description |
|---|---|---|---|
input |
Input | none | The gate's input. |
NotGate - 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 { NotGate } = require("@jaimermxd/logic-gates");
var gate = NotGate.create([false, true]);
console.log(gate.input); // [ false, true ]
console.log(gate.output); // [ true, false ]
console.log(gate.truthTable);
/*
[
[ false, false, [ true, true ] ],
[ false, true, [ true, false ] ],
[ true, false, [ false, true ] ],
[ true, true, [ false, false ] ]
]
*/
var table = NotGate.getTruthTable(3);
console.log(table);
/*
[
[ false, false, false, [ true, true, true ] ],
[ false, false, true, [ true, true, false ] ],
[ false, true, false, [ true, false, true ] ],
[ false, true, true, [ true, false, false ] ],
[ true, false, false, [ false, true, true ] ],
[ true, false, true, [ false, true, false ] ],
[ true, true, false, [ false, false, true ] ],
[ true, true, true, [ false, false, false ] ]
]
*/