🔌
nand2tetris
  • Introduction
  • Combinational Chips
    • Nand Gate
    • Not Gate
    • And Gate
    • Or Gate
    • Xor Gate
    • Multiplexor Chip
    • Demultiplexor Chip
    • Not16 Chip
    • And16 Chip
    • Or16 Chip
    • Mux16 Chip
    • Or8Way Chip
    • Mux4Way16 Chip
    • Mux8Way16 Chip
    • DMux4Way Chip
    • DMux8Way Chip
    • Half Adder Chip
    • Full Adder Chip
    • Add16 Chip
    • Inc16 Chip
    • Half Subtractor Chip
    • Full Subtractor Chip
    • Subtract16 Chip
    • Dec16 Chip
    • Arithmetic Chip
    • ALU
  • Misc
    • Int2Bool
    • Bool2Int
    • Arrayto16
Powered by GitBook
On this page
  1. Misc

Int2Bool

Misc is a package in Java™ Implementation of nand2tetris. It contains basic utilites and reusable codes for creation and modification of chips and its outputs.

Int2Bool Method in class Convert

Input: Integer

Output: Boolean

    public static boolean Int2Bool(int value) {
        boolean bool;
        if (value == 1) {
            bool = true;
        } else {
            bool = false;
        }
        return bool;
    }

Unlike most programming languages, Java treats boolean and integer data types unusually. However, some of the implemented gates takes values in the form of binary integral values (0 or 1). Therefore, a method Int2Bool is created to convert binary integrall values (0 and 1) to boolean (true and false) for faster comparisons.

PreviousALUNextBool2Int

Last updated 3 years ago