Comparing X ^ Y and Y ^ X for very large values of X and Y | Java implementation of the approach ; Function to compare x ^ y and y ^ x ; Storing values OF x ^ y AND y ^ x ; Comparing values ; Driver code
import java . util . * ; class GFG { static void compareVal ( int x , int y ) { double a = y * Math . log ( x ) ; double b = x * Math . log ( y ) ; if ( a > b ) System . out . print ( x + " ^ " + y + " ▁ > ▁ " + y + " ^ " + x ) ; else if ( a < b ) System . out . print ( x + " ^ " + y + " ▁ < ▁ " + y + " ^ " + x ) ; else if ( a == b ) System . out . print ( x + " ^ " + y + " ▁ = ▁ " + y + " ^ " + x ) ; } public static void main ( String [ ] args ) { int x = 4 , y = 5 ; compareVal ( x , y ) ; } }