Why 10^10 is 2147483647 not 10000000000 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why 10^10 is 2147483647 not 10000000000 ?

I am writing code in kotlin who gives power of any value . But when I am enter num:10 , power: 10 it gives 2147483647 i don't understand why ? Anyone can tell why this output gives ? https://code.sololearn.com/cxkwD2Ze6LYT/?ref=app

22nd Apr 2022, 5:13 AM
Akash Agrawal
Akash Agrawal - avatar
3 Answers
+ 9
Because that is the highest value an integer can store. Use Long to reach 9,223,372,036,854,775,807.
22nd Apr 2022, 5:24 AM
John Wells
John Wells - avatar
+ 4
In Kotlin the integer type is 32 bits long, this the max value is 2,147,483,647.
22nd Apr 2022, 5:23 AM
William Owens
William Owens - avatar
+ 3
William Owens & John Wells Thanks for solving problems ☺️
22nd Apr 2022, 5:38 AM
Akash Agrawal
Akash Agrawal - avatar