Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modulo operator

Status
Not open for further replies.

Sunseeker

IS-IT--Management
Jun 26, 2002
10
DE
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
 
thanks so far but sorry, it doesn't work!
i can't generate an array of long, and i use int for variables which have a maximum of one digit.
any more ideas

Sun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top