# -1#IND

This topic is 4963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am getting the strangest output from this code: #include <cstdlib> #include <iostream> #include <math.h> using namespace std; class Vector3 { public: double x; double y; double z; double dot(Vector3 w) { return (x*w.x + y*w.y + z*w.z); } double length() { return (sqrt(x*x + y*y + z*z)); } void Normalize() { double len = length(); x /= len; y /= len; z /= len; } Vector3 cross(Vector3 w) { Vector3 product; product.x = y*w.z - z*w.y; product.y = z*w.x - x*w.z; product.z = x*w.y - y*w.x; return(product); } }; int main(int argc, char *argv[]) { float acc,dec,len; Vector3 myvector; acc = 0; dec = 0; len = 0; myvector.x = 0; myvector.y = 0; myvector.z = 0; myvector.Normalize(); cout << myvector.x << endl << myvector.y << endl << myvector.z << endl; system("PAUSE"); return EXIT_SUCCESS; } And the output is this: -1.#IND -1.#IND -1.#IND Press any key to continue . . . The code compiles, but does not display properly. I am wondering what the problem is. Does anyone know?

##### Share on other sites
divide by zero :)

##### Share on other sites
You're dividing by zero (which is undefined). #IND basically means NaN(Not a Number).

EDIT: Gah, too slow!

##### Share on other sites
Well, you're dividing by zero. What you're getting is a string representation of the special float value representing infinity.

##### Share on other sites
Oh. I understand.

Thanks a lot!

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013593
×