hi folks,
as far as i know, you can't display a number with 20 digits.
so i wrote a programm, that splits the 20 digit number into single digits.
then i write every digit into a field of an array.
print out the fields of the array and i can see every digit of my number. so far so good. th program works fine with 2^40 for example but it gives a wrong value for 2^64.
who can help me out?
import java.lang.Math;
class conv
{
public static void main (String args [])
{
double x,
y;
int i,
z,
digit[] = new int[31];
x = Math.pow (2,64);
for (i=1; i<30; i++)
{
y = x%10;
z = (int)y;
digit = z;
x= x - y;
x= x / 10;
if (x<1) break;
}
for (; i>0; i--)
{
System.out.print(digit);
}
}
}
regards Sun
as far as i know, you can't display a number with 20 digits.
so i wrote a programm, that splits the 20 digit number into single digits.
then i write every digit into a field of an array.
print out the fields of the array and i can see every digit of my number. so far so good. th program works fine with 2^40 for example but it gives a wrong value for 2^64.
who can help me out?
import java.lang.Math;
class conv
{
public static void main (String args [])
{
double x,
y;
int i,
z,
digit[] = new int[31];
x = Math.pow (2,64);
for (i=1; i<30; i++)
{
y = x%10;
z = (int)y;
digit = z;
x= x - y;
x= x / 10;
if (x<1) break;
}
for (; i>0; i--)
{
System.out.print(digit);
}
}
}
regards Sun