0
Why this code doesn't work?
I know it's uncomplete, but the function to convert a decimal into a binary number doesn't work, and it should. I'm new in web programming so many things escape from my knowledge. Thanks for answering. https://code.sololearn.com/W3556P4fRpgo/?ref=app
8 ответов
+ 3
create a new code and copy and paste this in your "javascript" tab, and then just run. you will have the same result of conversion, no need for that much of code you did. Then just apply it for your code.. i recommend looking for the toSting() and parseInt() methods on Google also so you can understand it better
window.onload = function (){
//our decimal value
var a = 90;
//transform it into a string of base 2(binary)
a = a.toString(2);
alert(a);
//our binary value
var b = 10101110;
//transform it from base 2, to base 10
b = parseInt(b,2);
alert(b);
}
+ 2
You're welcome. very useful, aren't they? i discovered their existance when making my Multiple Color Picker code in which i needed to convert from the base 10 to the base 16 and vice-versa :)
+ 2
you probably made aome mistake while adapting it to your code
+ 1
Oh, I didn't know those methods. Thanks Will.
+ 1
Yup, of course I will use it on future codes haha
0
Sorry for the mess in there haha
0
What? For some reason it isn't working. The result returns as the same number
0
I suppose it is that. I'll try to remake the code. Thanks!