+ 1
Can you explain why int ("10000" , 3) is 81
In an education video result is 81. Can you explain why?
4 Answers
+ 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
+ 6
Because the string is parsed in base 3
+ 2
Sorry i ran this program int a= ("1000",3); cout<<a;
Its print 3 ).
+ 2
I got it now thanks for the answer