Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 43 results for
dectobin
- Page 1
adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
… #include <string> using namespace std; void
decToBin
(int number, int base); int main() { int answer…;< name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" <… int i=0; i<name.size(); i++) {
decToBin
(name[i],2)=answer; answer=answer/10; cout<<…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by andor
…lt;< name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" <…lt;< name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" <&…;<endl; system("PAUSE"); return 0; } void
decToBin
(int number, int base) { if (number>0)…
splitting a string to many integers
Programming
Software Development
17 Years Ago
by insamd
…; #include <string> using namespace std; void
decToBin
(int number, int base); int main() { int decimalNumber;…quot;<<decimalNumber<<" = ";
decToBin
(decimalNumber, base); cout<<" Binary"<…system("PAUSE"); return 0; } void
decToBin
(int number, int base) { if (number>0…
Re: splitting a string to many integers
Programming
Software Development
17 Years Ago
by andor
…include <string> using namespace std; void
decToBin
(int number, int base); int main() { …lt; name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" … } return 0; } void
decToBin
(int number, int base) { if (number>0) {
decToBin
(number/base, base); cout …
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by andor
[quote=isamd] [code]
decToBin
(name[i],2)=answer; [/code] [/quote] This is illegal. What did you want with this line?
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
i was trying to make it into an integer, because when i try to just div 10 the
decToBin
(name[i],2) it won't let me... thats my understanding of what i had to do. But it didn't work. So yeah thats why i am asking here, sorry limited knowledge :(
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
…++) { cout << name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" <<…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by andor
…++) { cout << name[i] << " binary (";
decToBin
(name[i], 2); cout << ")" <<…
Help with this code
Programming
Software Development
17 Years Ago
by geek
…*/ class Convert { public: Convert();/*Constructor: default parameters*/ void
DecToBin
(int); /*Dec to Hex*/ void PrintResult(); ~Convert(); /*Destructor…lt;<endl; } /*Dec to Bin*/ void Convert::
DecToBin
(int Results) { Result=Results; if((Result>=1…
Help Writing my own Base64 Functions..
Programming
Software Development
12 Years Ago
by triumphost
…) ((char)(n)) #define Ord(c) ((int)(unsigned char)(c)) int
DecToBin
(int Num) { int Bin = 0, Pos = 1; while (Num >… for (unsigned short I = 0; I < STE_Size; I++) Binaries(
DecToBin
(Ord(StringToEncode[I]))); //Binaries now holds an array of Binary…
Re: Help Writing my own Base64 Functions..
Programming
Software Development
12 Years Ago
by histrungalot
… namespace std; #define Ord(c) ((int)(unsigned char)(c)) string
DecToBin
(int Num){ int Bin = 0, Pos = 1; stringstream SS; while…; for (unsigned short I = 0; I < STE_Size; I++) bin +=
DecToBin
(Ord(StringToEncode[I])); //Binaries now holds an array of Binary…
need help on converting decimal to binary number
Programming
Software Development
9 Years Ago
by iikitty
… last for every execution and I dun know why... void
dectobin
(){ cout<<"Please input the decimal number to…<<"B"<<endl; } int main(){
dectobin
(); return 0; } Thanks for any help in advance.
Vector of strings to vector of ints
Programming
Software Development
10 Years Ago
by dirtydit27
…;array> #include <sstream> using namespace std; int
dectobin
() { return 0; } int dectooct() { return 0; } int bintodec() {return 0…
Re: Stable port number ??
Programming
Software Development
13 Years Ago
by pardeep3dec
…Debug.Print "VentID2" Debug.Print VentID2
DecToBin
VentID1, VentID2 Debug.Print AlarmCode Debug.Print &…Debug.Print "VentID2" Debug.Print VentID2
DecToBin
VentID1, VentID2 Debug.Print AlarmCode Debug.Print &….Print "VentID2" Debug.Print VentID2
DecToBin
VentID1, VentID2 Debug.Print AlarmCode Debug.Print &…
Re: number systems table c++
Programming
Software Development
13 Years Ago
by caut_baia
…include <string> #include <sstream> std::string
DecToBin
(int); int DecToHex (int); int main () { std::cout …<<
DecToBin
(44531) << "\n"; std::cout <… i >> x; return x; } std::string
DecToBin
(int Nb) { int exp=2; std::string Bin; while…
Re: Convert from Binary to decimal
Programming
Software Development
8 Years Ago
by Ion_1
…<iostream> std::vector<int>
DecToBin
(int n) { std::vector<int> output…== 1) { output.push_back(1); return output; } output.swap(
DecToBin
(n / 2)); output.push_back(n % 2); return output; }…char* argv[]) { std::vector<int> x =
DecToBin
(10); for(int i = 0; i < x…
Re: delegates
Programming
Software Development
18 Years Ago
by beuls
…> //Function to convert decimal to binary public static string
dectobin
(int n) { string s=""; int r; while (n…[] args) { //Creating a delegate object deldectobin del; del=new deldectobin(
dectobin
); delbintodec delb; delb=new delbintodec(bintodec); int t=0; int…
Re: Need to separate 16 bit binary to 4bit and 12 bit binary values
Programming
Software Development
15 Years Ago
by Teropod
… can just use these function. Its also simple. [CODE]Function
DecToBin
(lonDec As Long, lonNumberOfBits As Long) As String Dim strBinMirror…(strBinMirror) strBinMirror = "0" & strBinMirror Next End If
DecToBin
= strBinMirror End Function[/CODE] Hope these two functions will help!
Re: Decimal to Binary Conversion (Python)
Programming
Software Development
14 Years Ago
by armored saint
… for the code to work) #!/usr/bin/env python import
dectobin
#Module...defined later import string #Module.....defined later a=int…; elif a==0: print "Binary: 0" else: list=
dectobin
.conv(a) list1=string.format(list) print "Binary: "…
Re: ASCII to Binary
Programming
Software Development
9 Years Ago
by castajiz_2
…{ int z=(int)array[i]; String binary=
decToBin
(z); concat=concat+CheckNumbersOfDigits(binary); concat+="-"…quot;0"+digit; } return digit; } public static String
decToBin
(int dec) { if (dec == 0) { return "…
Re: Convert from Binary to decimal
Programming
Software Development
8 Years Ago
by Ion_1
Here is a nifty way of doing it: int*
DecToBin
(int n, int* output) { if(n == 0) return &(*output = …0); if(n == 1) return &(*output = 1); output =
DecToBin
(n / 2, output); return &(*(++output) = n % 2); } in the…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by andor
A litle of help. In your for loop you can make a temp array wich will convert the name[i] to decimal with atoi. [code] char tmp[2] = { 0, 0 }; tmp[0] = name[i]; answer = atoi(tmp); [/code] [quote] and then join them together [/quote] Figure this out
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by WaltP
I think some major clarificarion is needed. [quote=insamd;245897]I was wondering if anyone can help me in terms of using atoi to get my my results to add the 1's of my binary output and then join them together... eg. 110101 and 100101 is 4 and 3 = 43. [/quote] Do you mean you want to convert series of 1's and 0's typed in by the user into it's [I]…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by grunge man
if im corect um u said u wanted to put together 4 and 3 to make 43 well u can do that by this math equation 4*10+3 then suplement thouthes for there bionary equivlents or whatever conversion u want. also if u wand the user to input the number you could do a*10+b. also if u wana do division lots of times it wont come out even so you have to use …
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
sorry about my explanation... i don't wish to change into decimal, i was wanting to get the output of the binary's and add each binary's 1's... 1101110 number of 1's = 5 1001101 number of 1's = 4 1011011 number of 1's = 5 Then join those numbers together, so the number would be 545. Sorry for the misunderstanding, my bad.
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by Dave Sinkula
Some basic parts: [code]#include <stdio.h> [COLOR="Blue"]int count_ones(const char *text) { int ones = 0; for ( ; *text; ++text ) { if ( *text == '1' ) { ++ones; } } return ones; }[/COLOR] int main(void) { const char *text[] = { "1101110", "1001101", "…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
thanks for your help guys appreciate it... i am struggling to grasp the concept! but not to worry, as i was going to ask if anyone knew of some good tutorials or books that i can get to gain a better understanding.. i just can't comprehend the logic to what i need to do. So i figure i need to go back to step 1. Thanks again guys.
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by Bench
That depends exactly what part you don't understand. Essentially, your problem seems to be about looping through arrays, and performing some operation on each element. If you're not comfortable with arrays, then do a google search for array tutorials, or check: [url]http://www.daniweb.com/tutorials/tutorial1732.html[/url] [url]http://www.…
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by michael!
[LEFT]Create a table of commonly used binary digits with decimal digits and just memorize it[/LEFT]
Re: adding numbers of binary output
Programming
Software Development
17 Years Ago
by insamd
hey thanks for your ongoing help andor, appreciate it. My only concern is that, no matter what string i put in, it outputs 4006960. I am getting closer, but not quite there... Maybe it is not being split up correctly. If i put in john i should get a value of: 4635 j has 4 1's. o has 6 1's. h has 3 1's. n has 5 1's. I tried a few changes …
1
2
Next
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC