# Inc16 Chip

### Inc16 (16-bit Incrementer) Chip

16-bit Incrementer chip is a special kind of Adder, used to increment a 16-bit input by 1.

```nand2tetris-hdl
Chip name: Inc16
Inputs: in[16]
Outputs: out[16]
Function: out=in+1
Comment: Integer 2’s complement addition.
Overflow is neither detected nor handled.
```

![While this diagram is not a 16-bit binary incrementer, the implementation is similar to this.](https://media.geeksforgeeks.org/wp-content/uploads/20210429115210/updatedIncre.jpeg)

### Implementation of 16-bit Incrementer Chip in HDL

The function in the above abstraction can help in the implementation of 16-bit Incrementer Chip.

{% hint style="info" %}
You can use the Add16 Chip you've built earlier.

Remember that 1 in 4-bit binary (say) is 0001.
{% endhint %}

```nand2tetris-hdl
CHIP Inc16 {
    IN in[16];
    OUT out[16];

    PARTS:
   Add16(a=in, b[0]=true, out=out);
}
```

### Implementation of 16-bit Incrementer Chip in Java™

*Similar to the Implementation in HDL*

```java
package CombChips;

class Inc16_Gate extends Add16_Gate {
    
    protected static int[] Inc16(int[] in) {
        int[] b = new int[16];
        b[b.length-1] = 1;

        return Add16(in, b);
    }
}
```

{% hint style="info" %}
The Most Significant Bit is dropped.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gittest2121.gitbook.io/nand2tetris/combinational-chips/inc16-chip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
