NaN
Hi, Im converting a double to a string which is output to an applet window and I am getting the value NaN (Not-aNumber)
here is what i am doing...
distance=distance+(Math.sqrt((x2-x1)^2))+(Math.sqrt((y2-y1)^2));//calculate distance by taking the positive of coord2-coord1 (using square root of a square)
Distance=Double.toString(distance);//export distance as string for printing
[466 byte] By [
thedigita] at [2007-10-2 9:39:28]

> Doh, that'll teach me for asking people how to do
> squares on irc
LOL :-)
Seriously, though, in situations like this, it's very important to test your assumptions. You assumed x^2 was a squaring operation. But yet, you got a result that suggested that that or one of your other assumptions was wrong. It would have been very easy to print out x^2 and a couple of other values to see what was going on.
You'd have seen some weird number and probably not deduced that ^ is XOR, but you'd have known it's NOT raising to a power.
People here are happy to help, but in the future, please use a debugger or some print statements to at least check the main values and flow of your code.
jverda at 2007-7-16 23:45:30 >

Thanks!
ive found out that i need to use..pow(x,2) but ci ant get this to recognise it...
xdouble=x2-x1;
ydouble=y2-y1;
distance=distance+(Math.sqrt(pow (xdouble, 2)))+(Math.sqrt(pow (ydouble,2)));//calculate distance by taking the positive of coord2-coord1 (using square root of a square)
Distance=Double.toString(distance);//export distance as string for printing
And you're taking the square root of the squares. Pythagoras is oftenmore useful (unless you live in Manhatten).double distance = Math.sqrt(Math.pow(xdouble, 2) + Math.pow(ydouble, 2));
once my float is converted to a string it is displayed for example as 1002.0, and the number should never have a decimal value (so is an integer). Is there any way I can display my string as an integer value? i.e without the .0 at the end?