malformed floating point literal

if i do this, its ok:

double c = 5e+2;

but if instead i do this, gives me that error msg:

int k1 = (int)(Math.random() * 3);

int ax = k1;

double c = 5e+ax;

why?

thanks in advance

[392 byte] By [newonthisa] at [2007-9-30 2:26:25]
# 1
You can use the "5e+2" format only to define literal floating point constants, not to do calculations. The correct way to write the same isdouble c = 5*Math.pow(10, ax);
jsalonena at 2007-7-16 13:36:25 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2
static double pow(double a, double b) Returns the value of the first argument raised to the power of the second argument. i missed it...thanks a lot!!
newonthisa at 2007-7-16 13:36:25 > top of Java-index,Archived Forums,New To Java Technology Archive...