Jump to content
  • Advertisement
Sign in to follow this  
generaltak

-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.

If you intended to correct an error in the post then please contact us.

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 this post


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

EDIT: Gah, too slow!

Share this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!