Challenge to new programmers!

Discussion in 'Programming General' started by Xeox, Oct 4, 2011.

Challenge to new programmers!
  1. Unread #1 - Oct 4, 2011 at 12:11 AM
  2. Xeox
    Joined:
    Jun 17, 2010
    Posts:
    357
    Referrals:
    0
    Sythe Gold:
    0

    Xeox Forum Addict
    Banned

    Challenge to new programmers!

    Make a program that prints out the binary representation of an integer. Does not have to deal with negatives. I will post my way of solving this in a week, maybe sooner. Oh and no it's not a homework assignment of mine!
     
  3. Unread #2 - Oct 4, 2011 at 12:19 AM
  4. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

  5. Unread #3 - Oct 4, 2011 at 12:20 AM
  6. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Challenge to new programmers!

  7. Unread #4 - Oct 4, 2011 at 12:39 AM
  8. Xeox
    Joined:
    Jun 17, 2010
    Posts:
    357
    Referrals:
    0
    Sythe Gold:
    0

    Xeox Forum Addict
    Banned

    Challenge to new programmers!

    Yea, it was a practice question for my first College CS exam, and I just thought it would liven things up a bit in the Java forum.
     
  9. Unread #5 - Oct 6, 2011 at 7:13 PM
  10. Romperin
    Joined:
    Apr 15, 2011
    Posts:
    487
    Referrals:
    2
    Sythe Gold:
    0

    Romperin Forum Addict
    Banned

    Challenge to new programmers!

    I will try this one day that I have some experience. I'm starting programming this week, but nto sure what language to start on.
     
  11. Unread #6 - Oct 26, 2011 at 3:57 AM
  12. nosaM eerF
    Joined:
    Feb 19, 2011
    Posts:
    132
    Referrals:
    0
    Sythe Gold:
    0

    nosaM eerF Active Member
    Banned

    Challenge to new programmers!

    didn't realize you could directly convert integers to hex, octal and binary so easily
     
  13. Unread #7 - Nov 10, 2011 at 5:53 PM
  14. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Challenge to new programmers!

    Code:
    public void intbin(int input)
    {
        int i;
        for(i = 0; i < 32; i++)
        {
            System.out.print(( input >> 31)&1);
            input <<= 1;
        }
        System.out.print("\n");
    }
    
    whadu i win
     
  15. Unread #8 - Jan 9, 2012 at 9:39 PM
  16. hell016
    Joined:
    Jan 9, 2012
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    hell016 Newcomer

    Challenge to new programmers!

    import javax.swing.*;
    public class DecToBin{
    public static void main(String [] args){
    int numDec=0
    String numBin="";
    numDec=Integer.parseInt(JOptionPane.showInputDialog("Enter a number:"));
    while(numDec>=1)
    {
    if(numDec==1){
    numBin="1"+numBin; break;
    }
    else{
    if(numDec%2==0)
    { numBin="0"+numBin;numDec/=2;}
    else
    { numBin="1"+numBin;numDec/=2;}
    }
    }
    JOptionPane.showMessageDialog(null,"Binary Number:"+numBin);
    System.exit(0);
    }
    }
    //i hope that this will work ^_^
     
  17. Unread #9 - Jan 10, 2012 at 6:51 PM
  18. LoveLover
    Joined:
    Dec 29, 2011
    Posts:
    69
    Referrals:
    0
    Sythe Gold:
    0

    LoveLover Member

    Challenge to new programmers!

    There are two binary representations, a mathematical and a computational.

    where 000... is -2,147,000,000 or something in computational
    and on a mathematical base 32 zeros would be 2^32.
    Which one are you referring to?
     
< Programmer For Hire | [Paying] For a basic program to be made for me >

Users viewing this thread
1 guest


 
 
Adblock breaks this site