Trying to make an algorithm to convert Dec to Bin, need to use an array with a decreasing index to give out the number is the right order, don't seem to be able to make it work.
How do I set the index properly? and how do I initiate the array to 0 when I-m converting small numbers?
Robert Torres
try N>-1 or N=>0 instead of N!=0.
Anthony Robinson
Uhhh, no that works, It's the For that-s not working
Ryan Long
ignore this output bin[i], don't you wanna return the whole array?
Luis Butler
what language/program is this?
Samuel Wood
Its called pseudo-code. Not language specific. Its meant to be a high-level human-readable format from which we can extrapolate that idea and translate it into any language form we want.
Cooper Lee
Well not really at that specific point, I just wanted to check the content of the array, isn't that how you do it? What I want to do at that point is just make another for cycle to print out Bin[i] in the right order. But I can't figure out what I'm doing wrong with the For conditions.
This, also gives out different codes translation for the algorithm. It's to get familiar with the logic.
Wyatt Foster
Your alg doesn't make sense, the for it's not necessary, you overwrite bin[i] every time without changing the index i = (int)(log(N)/log(2)); do{ bin[i] = N%2; N /= 2; --i; }while(N!=0)
Or better
arrayDim = (int)(log(N)/log(2)); for(i=arrayDim;i
Dylan Jackson
If you have an array of five (and then a decimal number under 2^5 = 128), just use five instead of log2
Juan Price
Hope it helps, if I'm wrong sorry, shame on me
Blake Garcia
it's not fucking pseudocode if you can execute it you goddamn moron
otherwise the syntax would be irrelevant, which it obviously isnt.
Camden Allen
>the for it's not necessary, you overwrite bin[i] every time
Fuck, original idea was to put the values of Bin in an array (Bin[i]) and then use another array to print it straight. I forgot the for was supposed to be for the index of the second array not Bin[i]. Maybe I can fix it.
It's a pseudocode with a syntax.
Jason Ward
What's your level with programming?
Adam Collins
I'm starting from scratch, trying to figure shit out
David Adams
Modularize your mind, make small step, don't rush a problem. You need to simplify everything. Personally I think that you must not bother with pseudocode, just use an interactive programming language and start from there, something like python that teaches you indentation too. Then jump on C or something more low level. Then try some high level language like java. If you do this maybe you'll end programming something useful, or maybe not, like me, who like fractran. Ps learn algebra Pss install gentoo, unironically
William White
here you go
Ryder Perry
Funny but it works.
Hunter Anderson
>Ps learn algebra At the moment, I'm thinking about giving up and find a dead end job and stop trying to be happy.
>Personally I think that you must not bother with pseudocode We just used it for a few weeks to wrap our mind around the basic logic of sequence, selection and iteration, next step is grabbin either arduino or raspberry and realize a small project, either with C or phyton.
Jaxson Parker
Convert to hex then convert to bin. It'll be easier and basically what computers do.
Jose Ortiz
>implying you can't be happy in a dead end job
Jace Campbell
Is this "pseudocode" an inside joke?
can someone explain? google doesn't give me an actual application
Easton Young
I think I would, I enjoy working with my hands more than with my brain. But I'm not as educated as my intelligence would require me to be, and that makes me unhappy, so I'm trying to fix that.
It's a simple to read code that's used to explain real code to people like me.
Jaxson Carter
Just find happiness in what you have/are, life it's too short. If you think that dropping everything it's good for you, then go for it, but usually the sufference and the hard work repays, maybe you'll not become richer, but you'll be a better person.
Adam Thompson
It's about the journey, not the destination
Landon Nguyen
Did that once already, dropped out of EE years ago (HS). it made me happier in the sense that I've found more immediate gratification, but I sure as hell wasn't going anywhere. I already have some options if I manage to finish the 3 years to get my degree, so I shuld really stick to it.
I'm also afraid I won't be able to keep up with this ever evolving field once i'm out, and realize that the skill I'm acquiring won't be sufficient.
Liam Jenkins
I understand, I'm at the edge of dropping my master degree in physics, but who knows, we will see... ㄟ(ツ)ㄏ
Jonathan Fisher
you can put it in front of a ton of things. specifically pseudocode means it is meant as a demonstration of how you would write the code, but it is not any real language, so you can't run it anywhere. It is often used for algorithms and when you explain stuff.
Christian Robinson
If he is trying to learn binary, why not use binary operators? arrayDim = static_cast(log(N)/log(2)); for(i=arrayDim;i
James Reed
but obviously OP is compiling and or running it otherwise he wouldn't know that it doesn't work.