Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Conversions/DecimalToBinary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package Conversions;

import java.util.ArrayList;

public class DecimalToBinary {

public static void main(String[] args) {
// Example to just show.
decimalToBcd(15);
}
/**
* Converts the decimal to Binary format.
*
* @input the integer that to be converted to binary.
*/
public static void decimalToBcd(int input) {
ArrayList<Integer> num = new ArrayList<Integer>();
while (input > 0) {
int temp = input % 2;
input = input / 2;
num.add(0, temp);
}
System.out.println(num.toString());
}
}