Decimal To Binary

out of curiousity

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

39 Replies - 21683 Views - Last Post: 07 December 2008 - 08:38 PM Rate Topic: -----

#1 miaka284  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 530
  • Joined: 10-May 01

Decimal To Binary

Posted 26 October 2004 - 11:11 AM

So... my bf is working on a program in VB on converting decimal numbers to binary numbers... i vaguely remember doing it in C++ LONG time ago... i was just wondering...if someone could refresh my memory of how to do it... you don't have to give code.. just explanation... because i remember doing it... but i don't use c++ any more so my coding is rusty....
Thx
Is This A Good Question/Topic? 0
  • +

Replies To: Decimal To Binary

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Decimal To Binary

Posted 26 October 2004 - 12:11 PM

While there are several tools to convert decimal numbers to binary, this page shows the two most common ways to do it. It's easy to translate the method into code.
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Decimal To Binary

Posted 26 October 2004 - 12:13 PM

Whoa, what's up Amy!
Was This Post Helpful? 0
  • +
  • -

#4 miaka284  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 530
  • Joined: 10-May 01

Re: Decimal To Binary

Posted 26 October 2004 - 03:08 PM

thx.... i have an idea of what to do... we will see... cuz there's another part to it.. that i absolutely don't understand... but i'll do more research on it...
Was This Post Helpful? 0
  • +
  • -

#5 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Decimal To Binary

Posted 26 October 2004 - 03:32 PM

Hi Amy, nice to see you too, I've been great... thanks for asking, oh, what I've been up to!? Eh, you know, same ole same ole. You?!
Was This Post Helpful? 0
  • +
  • -

#6 miaka284  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 530
  • Joined: 10-May 01

Re: Decimal To Binary

Posted 26 October 2004 - 03:38 PM

HI chris.. i am sorry that you felt ignored.. but i was trying to keep a technical post TECHNICAL and not social.... and how are you.. how have you been and how's business....... *thinking to self.. god... he is an attention monger*
Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Decimal To Binary

Posted 26 October 2004 - 03:40 PM

I've been good, check out my latest project

http://www.mg1hosting.com
Was This Post Helpful? 0
  • +
  • -

#8 miaka284  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 530
  • Joined: 10-May 01

Re: Decimal To Binary

Posted 26 October 2004 - 03:46 PM

da link don't work
Was This Post Helpful? 0
  • +
  • -

#9 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Re: Decimal To Binary

Posted 26 October 2004 - 06:24 PM

skyhawk133, on Oct 26 2004, 04:40 PM, said:

I've been good, check out my latest project

http://www.mg1hosting.com

yeah chris, that pretty much sums you up

http://www.mg1hosting.com
Was This Post Helpful? 0
  • +
  • -

#10 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Decimal To Binary

Posted 26 October 2004 - 07:05 PM

I'm not sure what you mean by more to it, but I'll try to help if you can explain it to me. The division method is uusally the easiest to represent in code. You can use the algorithm outlined here
I may be misunderstanding your question, however. If so, my apologies.

This post has been edited by Amadeus: 26 October 2004 - 07:06 PM

Was This Post Helpful? 0
  • +
  • -

#11 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Decimal To Binary

Posted 26 October 2004 - 09:32 PM

Nova Dragoon, on Oct 26 2004, 07:24 PM, said:

skyhawk133, on Oct 26 2004, 04:40 PM, said:

I've been good, check out my latest project

http://www.mg1hosting.com

yeah chris, that pretty much sums you up

http://www.mg1hosting.com

Inside joke... you wouldn't understand.
Was This Post Helpful? 0
  • +
  • -

#12 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Decimal To Binary

Post icon  Posted 30 December 2004 - 02:33 AM

Wierd....I thought every1 out here knew how to convert Decimal to Binary....well since noone gave the method anyhow....here's my code...simple as it is....still if you have any problems let me know.
There are many ways of doing this...out of which I'll explain two. Here's the First one...in which you dont even have to bother about how the conversion is done:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

void main()
{
int i=23;
char c[23];
clrscr();
cout<<"Enter any Number in Decimal to be converted in Binary\n";
cin>>i;
cout<<itoa(i,c,2);
getch();
}



Here's the Second Method:
#include <iostream.h>
#include <conio.h>


void main()
{
      int i, ch;
      cout<<"Enter an integer: ";
      cin>>ch;
      for(i=0x80;i;i=i>>1)
	cout<<((ch&i)?'1':'0');

      getch();
      /*
      these 2 lines are equivalent to:
      i=0x80; //10000000 in binary
      while (i!=0)
          {
         	 if (ch&i)
            cout<<'1';
         	 else
            cout<<'0';
         	 i>>1;
          }
       */
       	 
}



Hope It helps you all.
Was This Post Helpful? 1

#13 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Decimal To Binary

Post icon  Posted 30 December 2004 - 02:38 AM

Man....real bad formatting style...the CODE tags really ruin everything up....I'm attaching the 2 methods of converting Decimal to Binary as 2 Source Code Files.

Great...I gotta reply again to add both the files...I think an improvement to this forums would be to attach multiple files. Or do they want us to attach ZIP Archives instead?
In any case....i'll reply once more...
This is the First Method

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#14 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Decimal To Binary

Post icon  Posted 30 December 2004 - 02:44 AM

Here's Method Number 2 Attached

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#15 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Decimal To Binary

Posted 30 December 2004 - 06:23 AM

Excellent methods. I'm not sure I'd agree that everyone would know how to do the conversion, there are several groups here, many of which deal with graphics and subjects other that programming.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3