Título: Problema con enteros muy grandes en Java Publicado por: Jota1948 en 31 Marzo 2014, 18:15 pm Hola a todos
Estoy haciendo un ejercicio en Java que solicita calcular si un número de 25 cifras o mayor es primo o no, funciona correctamente hasta 18 cifras, pero de ahí en adelante no deja hacer nada, agradezco quien me pueda dar una manita a ver que puede estar faltando Código: import javax.swing.*; Muchas gracias por su ayuda Título: Re: Problema con enteros muy grandes en Java Publicado por: 1mpuls0 en 31 Marzo 2014, 18:57 pm e.e quien rayos querría hacer eso.
Posiblemente BigDecimal puede ayudarte. Ejemplos: http://www.tutorialspoint.com/java/math/bigdecimal_max.htm http://www.java2s.com/Code/JavaAPI/java.math/BigDecimal.htm Documentación http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html Citar Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale. The value of the number represented by the BigDecimal is therefore (unscaledValue × 10-scale) Título: Re: Problema con enteros muy grandes en Java Publicado por: Jota1948 en 31 Marzo 2014, 19:29 pm e.e quien rayos querría hacer eso. Posiblemente BigDecimal puede ayudarte. Ejemplos: http://www.tutorialspoint.com/java/math/bigdecimal_max.htm http://www.java2s.com/Code/JavaAPI/java.math/BigDecimal.htm Documentación http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html Gracias por tu respuesta, a nuestro profesor le dio por poner eso de tarea y la verdad no es que seamos muy fuertes programando. Título: Re: Problema con enteros muy grandes en Java Publicado por: 1mpuls0 en 31 Marzo 2014, 19:46 pm De nada.
Comenta si tienes dudas. Por cierto por qué tu algoritmo lo tienes así?. Así les pidieron específicamente el método? |