for the number which we want to convert we need to multiply by that number number base and for base to be which we want to convert we need to divide by that ! Simple eg 673 base 10 to base 8 then divide by 8 get the value and multiply by 10 rase to pow++;
Thankyou beta for being our constant supporter🙏 If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms ) Keep learning and keep loving Pepcoding😊
Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Gurudev jab bhi concept aap explain karte ho paint se to kripya kar ke code ko bhi laa kar explain kar diya karo ishe code ke follow ko relate karne main aashan ho jayega warna speed kam kar ke TH-cam ka multiple time suna aur samjhna parta hai 🙏
public static int getValueIndecimal(int n, int b) { // write your code here int sum = 0; int i = 0; while (n > 0) { int dig = n % 10; n = n / 10; sum += dig * (Math.pow(b, i)); i++; } return sum; }
for the number which we want to convert we need to multiply by that number number base and for base to be which we want to convert we need to divide by that ! Simple
eg 673 base 10 to base 8 then divide by 8 get the value and multiply by 10 rase to pow++;
sir will it work correctly for hex numbers?
nahi bro. 10 base tak he chalega.
Thanks
For hexadecimal we need to collect 16 ke power.
Sir can we use math.pow and solve this
Thank you so much sir🙏
Thankyou beta for being our constant supporter🙏
If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Keep learning and keep loving Pepcoding😊
@@Pepcoding done sir😁
Thank you sir
Thankyou beta!
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Perfect
Sir question clear nhi ho raha...base 8 kaise pata chala??? confused
8 is taken just for example you can try with base 2 also.
Gurudev jab bhi concept aap explain karte ho paint se to kripya kar ke code ko bhi laa kar explain kar diya karo ishe code ke follow ko relate karne main aashan ho jayega warna speed kam kar ke TH-cam ka multiple time suna aur samjhna parta hai 🙏
ok ji
public static int getValueIndecimal(int n, int b) {
// write your code here
int sum = 0;
int i = 0;
while (n > 0) {
int dig = n % 10;
n = n / 10;
sum += dig * (Math.pow(b, i));
i++;
}
return sum;
}