+ 1

Can you explain why int ("10000" , 3) is 81

In an education video result is 81. Can you explain why?

13th Nov 2017, 8:08 AM
Timuçin Küçük
Timuçin Küçük - avatar
4 ответов
+ 8
Because, you set it as a base 3 number. From the right most number going left (right to left) you have the ones place, threes place, nines place, twenty-sevens place, eighty-ones place. The only place that has a value is 81. Try running the following to help you understand: print(int("1", 3)) print(int("10", 3)) print(int("100", 3)) print(int("1000", 3)) print(int("10000", 3)) since it's base 3 each place can hold 1 of three values (0, 1, or 2) which is then multiplied by its place and added to the next place and so on. So, print(int("202", 3)) would equal (2*9)+(0*3)+(2*1) = 20
13th Nov 2017, 9:04 AM
ChaoticDawg
ChaoticDawg - avatar
+ 6
Because the string is parsed in base 3
13th Nov 2017, 9:47 AM
David Akhihiero
David Akhihiero - avatar
+ 2
Sorry i ran this program int a= ("1000",3); cout<<a; Its print 3 ).
13th Nov 2017, 8:34 AM
Bhavin Kundaliya
Bhavin Kundaliya - avatar
+ 2
I got it now thanks for the answer
13th Nov 2017, 9:51 AM
Timuçin Küçük
Timuçin Küçük - avatar