/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.edu.amu.wmi.dino.ultrapotegowanie;

import java.util.Random;

/**
 *
 * @author bikol
 */
public class UltraPotegowanie {
    /**
     * Zwaraca wartość a^b.
     * @param a
     * @param b
     * @return 
     */
    public static String poteguj(String a, String b){
        //Mikołaj Szumigalski
        double aa = Double.parseDouble(a); // działa dla double
        double bb = Double.parseDouble(b);
        long c = Math.round(Math.pow(aa, bb)); // zaokrąglanie liczb typu 1.0 do 1
        if(aa == 0 && bb != 0){
            String xo = new String("0");
            return xo;
        }                
        if(0 != Math.pow(aa, bb)%c){
            if(bb == -2){
                double cc = Math.pow(aa, bb);
                String xo = String.format("%.12f", cc).replace(",",".");
                return xo;                
            }
            else
                return Double.toString(Math.pow(aa,bb));
        }
        else
            return Long.toString(c);
    }
    
}
@@ -325,16 +325,22 @@
 anie %7B%0D%0A
+    %0D%0A
     /**%0D
@@ -496,148 +496,114 @@
     
-//Miko%C5%82aj Szumigalski%0D%0A        double aa = Double.parseDouble(a); // dzia%C5%82a dla double%0D%0A        double bb = Double.parseDoubl
+double aa;%0D%0A        double bb;%0D%0A%0D%0A        aa = szesnastkowe(a);%0D%0A        bb = szesnastkow
 e(b);%0D%0A
+%0D%0A
         
 long
@@ -602,82 +602,40 @@
     
-long c = Math.round(Math.pow(aa, bb)); // zaokr%C4%85glanie liczb typu 1.0 do 1
+double power = Math.pow(aa, bb);
 %0D%0A  
@@ -693,23 +693,11 @@
 o = 
-new String(
 %220%22
-)
 ;%0D%0A 
@@ -728,24 +728,26 @@
        %7D
+%0D%0A
         
         
@@ -742,81 +742,134 @@
     
-        %0D%0A        if(0 != Math.pow(aa, bb)%25c)%7B%0D%0A            if(bb == -2)%7B
+if (power %25 1 == 0)%0D%0A               return Long.toString(Math.round(power));%0D%0A        String result =  Double.toString(power);
 %0D%0A  
@@ -878,74 +878,54 @@
     
- 
-       double cc = Math.pow(aa, bb);%0D%0A                String xo =
+if (result.contains(%22E%22))%7B%0D%0A            return
  Str
@@ -948,10 +948,13 @@
 f%22, 
-cc
+power
 ).re
@@ -970,32 +970,35 @@
 ,%22.%22);%0D%0A        
+%7D%0D%0A
         return x
@@ -1000,187 +1000,419 @@
 urn 
-xo;
+result;%0D%0A
     
+%7D%0D%0A
     
-        %0D%0A            %7D%0D%0A            else%0D%0A                return Double.toString(Math.pow(aa,bb));%0D%0A        %7D%0D%0A        else%0D%0A            return Long.toString(c
+public static double szesnastkowe(String a)%7B%0D%0A        if(a.contains(%220x%22))%7B%0D%0A        String digits = %220123456789ABCDEF%22;%0D%0A        double val = 0;%0D%0A        for (int i = 2; i %3C a.length(); i++)%7B%0D%0A            char c = a.charAt(i);%0D%0A            int d = digits.indexOf(c);%0D%0A            val = 16*val + d;%0D%0A        %7D%0D%0A        return val;%0D%0A        %7Delse%7B%0D%0A        return Double.parseDouble(a
 );%0D%0A    
 %7D%0D%0A 
@@ -1411,14 +1411,21 @@
     
+  
+  
 %7D%0D%0A    
+%7D
 %0D%0A%7D
+%0D%0A

Update UltraPotegowanie.java