Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Binär{
- public String toBinary(int n){
- // 1. Erzeuge einen leeren String
- String output= "";
- // 2.
- int wert = 16;
- do{
- if (n % 2 == 0){
- output = "0" + output;
- }else{
- output = "1" + output;
- }
- n = n / 2;
- }while(n > 0);
- // 3. Gib den fertigen String zurück
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement