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
Decimal To Binaryout of curiousity
39 Replies - 20641 Views - Last Post: 07 December 2008 - 08:38 PM
Replies To: Decimal To Binary
#4
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...
#5
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?!
#6
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*
#7
Re: Decimal To Binary
Posted 26 October 2004 - 03:40 PM
#9
Re: Decimal To Binary
Posted 26 October 2004 - 06:24 PM
skyhawk133, on Oct 26 2004, 04:40 PM, said:
yeah chris, that pretty much sums you up
http://www.mg1hosting.com
#10
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.
I may be misunderstanding your question, however. If so, my apologies.
This post has been edited by Amadeus: 26 October 2004 - 07:06 PM
#11
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:
yeah chris, that pretty much sums you up
http://www.mg1hosting.com
Inside joke... you wouldn't understand.
#12
Re: Decimal To Binary
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:
Here's the Second Method:
Hope It helps you all.
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.
#13
Re: Decimal To Binary
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
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)
-
dec2bin.cpp (225bytes)
Number of downloads: 117
#14
Re: Decimal To Binary
Posted 30 December 2004 - 02:44 AM
Here's Method Number 2 Attached
Attached File(s)
-
DEC2BIN2.CPP (498bytes)
Number of downloads: 97
#15
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.
|
|

New Topic/Question
Reply




MultiQuote





|