Qual o Maior e o menos valor em Hexadecimal que um int do Java pode Representar

5 respostas
A

Alguem poderia me ajudar?

5 Respostas

ViniGodoy

Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.

System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER);

JavaDreams
ViniGodoy:
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.
System.out.println("%x", Integer.MAX_INTEGER);
System.out.println("%x", Integer.MIN_INTEGER);

Vini eu queria aprender essa dica mas tive um erro aqui

código
public class NewClass {
    
    public static void main(String [] args){
        System.out.println("%x", Integer.MAX_INTEGER);  
        System.out.println("%x", Integer.MIN_INTEGER); 
    }
    
}

exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

Fiz isso no NBeans.

abraço.

Ataxexe
JavaDreams:
ViniGodoy:
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.
System.out.println("%x", Integer.MAX_INTEGER);
System.out.println("%x", Integer.MIN_INTEGER);

Vini eu queria aprender essa dica mas tive um erro aqui

código
public class NewClass {
    
    public static void main(String [] args){
        System.out.println("%x", Integer.MAX_INTEGER);  
        System.out.println("%x", Integer.MIN_INTEGER); 
    }
    
}

exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

Fiz isso no NBeans.

abraço.

Você não compilou o código (esse erro ocorre quando o IDE vai rodar o código e ele não pôde ser compilador porque tinha erros). Ao compilar, verá alguns erros. Um código correto é:

public class NewClass {  

    public static void main(String [] args) {
        System.out.printf("%x%n", Integer.MAX_VALUE);
        System.out.printf("%x%n", Integer.MIN_VALUE);
    }  

}
JavaDreams
Ataxexe:
JavaDreams:
ViniGodoy:
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.
System.out.println("%x", Integer.MAX_INTEGER);
System.out.println("%x", Integer.MIN_INTEGER);

Vini eu queria aprender essa dica mas tive um erro aqui

código
public class NewClass {
    
    public static void main(String [] args){
        System.out.println("%x", Integer.MAX_INTEGER);  
        System.out.println("%x", Integer.MIN_INTEGER); 
    }
    
}

exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

Fiz isso no NBeans.

abraço.

Você não compilou o código (esse erro ocorre quando o IDE vai rodar o código e ele não pôde ser compilador porque tinha erros). Ao compilar, verá alguns erros. Um código correto é:

public class NewClass {  

    public static void main(String [] args) {
        System.out.printf("%x%n", Integer.MAX_VALUE);
        System.out.printf("%x%n", Integer.MIN_VALUE);
    }  

}

Ok, agora consegui.

Saída foi:

run:
7fffffff
80000000
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

É isso mesmo?

ViniGodoy

Isso aí, eu comi bola, era printf ali.

Criado 4 de agosto de 2013
Ultima resposta 21 de ago. de 2013
Respostas 5
Participantes 4