+ 5

How to initialise the power of number without using .math package in java ...??

27th Apr 2017, 11:29 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
8 odpowiedzi
+ 30
Math.pow(2,3), here 2 is base and 3 is power. You don't need to import any package. Did you mean without using any library function? Hint: To calculate 2^3 using loop, you need to multiply 2 with itself 3 times. 2^3 = 2*2*2
27th Apr 2017, 11:40 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 27
You can't initialize using ^ operator. It has different meaning. There's no such operator for power. You'll have to use library function Math.pow()
27th Apr 2017, 1:06 PM
Shamima Yasmin
Shamima Yasmin - avatar
27th Apr 2017, 12:10 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
i know this method but i want to solve without using this function ... if you know the so tell me
27th Apr 2017, 11:43 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 2
i want to initialise 🙄
27th Apr 2017, 12:18 PM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 2
int i=10; int j=1; int k=i^j; 👆👆 i want to initialise like this but I don't know perfect coding .... anybody know the answer please suggest me...
27th Apr 2017, 12:51 PM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 1
Are you talking about finding the power without using any functions ?
27th Apr 2017, 12:41 PM
Nantha
Nantha - avatar
0
you have to use math.pow it's return type is double .so u have to do type casting INT k=Integer.parseInt(math.pow(i,j)) or INT k= (int)math.pow(i,j)
27th Apr 2017, 12:55 PM
Nantha
Nantha - avatar