A small Java console project for practicing number conversion logic.
NumberConverter is a small Java console project for converting numbers between different number systems and calculating usable hosts from IPv4 CIDR prefixes.
It supports:
- decimal to binary conversion
- binary to decimal conversion
- decimal to hexadecimal conversion
- hexadecimal to decimal conversion
- hexadecimal to binary conversion
- binary to hexadecimal conversion
- CIDR prefix to usable hosts calculation
- basic input validation
- repeated input prompts until the user enters a valid value
- large-number conversion in
NumberConverterAppviaBigInteger
This repository is intentionally simple. It is a learning project, not a production application.
The repository license is not finalized yet.
- Java
- Console / CLI application
- No external dependencies
src/NumberConverterApp.java- main menu app for the available converter directions and CIDR prefix calculatorsrc/IntegerToBinary.java- standalone decimal-to-binary practice classsrc/BinaryToInteger.java- standalone binary-to-decimal practice classsrc/IntegerToHexadecimal.java- standalone decimal-to-hexadecimal practice classsrc/HexadecimalToInteger.java- standalone hexadecimal-to-decimal practice classsrc/HexadecimalToBinary.java- standalone hexadecimal-to-binary practice classsrc/BinaryToHexadecimal.java- standalone binary-to-hexadecimal practice classsrc/CidrPrefixToUsableHosts.java- standalone CIDR-prefix-to-usable-hosts practice class
New-Item -ItemType Directory -Force out | Out-Null
javac -d out src\*.java
java -cp out NumberConverterAppRun a standalone practice converter:
java -cp out IntegerToBinary
java -cp out BinaryToInteger
java -cp out IntegerToHexadecimal
java -cp out HexadecimalToInteger
java -cp out HexadecimalToBinary
java -cp out BinaryToHexadecimal
java -cp out CidrPrefixToUsableHostsmkdir -p out
javac -d out src/*.java
java -cp out NumberConverterAppRun a standalone practice converter:
java -cp out IntegerToBinary
java -cp out BinaryToInteger
java -cp out IntegerToHexadecimal
java -cp out HexadecimalToInteger
java -cp out HexadecimalToBinary
java -cp out BinaryToHexadecimal
java -cp out CidrPrefixToUsableHostsDecimal to binary:
Enter a decimal number: 10
1010
Binary to decimal:
Enter a binary number: 1010
10
Decimal to hexadecimal:
Enter a decimal number: 255
FF
Hexadecimal to decimal:
Enter a hexadecimal number: FF
255
Hexadecimal to binary:
Enter a hexadecimal number: FF
11111111
Binary to hexadecimal:
Enter a binary number: 11111111
FF
CIDR prefix to usable hosts:
Enter a CIDR prefix, for example /28 or 28: /28
Prefix: /28
Host bits: 4
Total addresses: 16
Usable hosts: 14
Main app menu:
Number Converter
1. Decimal to binary
2. Binary to decimal
3. Decimal to hexadecimal
4. Hexadecimal to decimal
5. Hexadecimal to binary
6. Binary to hexadecimal
7. CIDR prefix to usable hosts
0. Exit
Choose an option:
This repo is open to small, focused improvements. Since this is a practice project, the goal is clarity and clean code rather than adding unnecessary complexity.
If you are reviewing or contributing:
- keep changes small and easy to review
- explain behavior changes in the commit or pull request
- prefer readability and input validation improvements
- discuss larger refactors before implementing them
- if a licensing detail matters for your contribution, discuss it first
For more detail, see CONTRIBUTING.md.
- add unit tests
- consider sharing conversion logic between the main app and standalone practice classes
- add octal conversion if another number system is useful for practice
- see ROADMAP.md for the longer product direction