cout value -1.07374e+008?

My program is to calculate the Vector X product using the Direct X Header/ Library
Iv'e got it to work something is wrong with the output of the Vectors

They all display " -1.07374e+008"

Header File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef _D3DXD9Vector_H_
#define _D3DXD9Vector_H_

#include <D3DX9.h>
#include <d3d9.h>
#include <D3DX9math.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <Windows.h>
#include <cctype>


D3DXVECTOR3 TargetVector(D3DXVECTOR3 *target, D3DXVECTOR3 *firer);
int Pointme(void);
int Mmenu(void);
bool checkme(void);
void showvector(void);


#endif


CPP File

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "D3DXD9Vector.h"

using namespace std;


int main()
{
	
	char name[20];
	int menu;

		cout<<"Welcome to enterprise calculation systems!\n";
		cout<<"Please enter your login credientials:\n[]:";
		cin>>name;

		menu = Mmenu();

}
int Mmenu(void)
{
	int input;
	int exit_flag=0;
	int points;
	
	

	while(exit_flag == 0)
	{	
			cout<<"Select what would you like to do?\n";
			cout<<"1. to run the program\n";
			cout<<"2. to view instructions on how it works\n";
			cout<<"3. exit the simulation\n";
			cin>>input;
			system("CLS");

			switch(input)
			{
				case 1:
					points = Pointme();
					system("CLS");
					break;
				case 2:
					system("CLS");
					cout<<"Instructions to run simulation:\n";
					cout<<"First input the 3 numbers that make up a vector\n";
					cout<<"Input the second batch\n";
					cout<<"It will calculate the dot/cross product\n\n"; 
					Sleep(2000);
					system("CLS");
					break;
				case 3:
					system("CLS");
					cout<<"Closing Simulation";
					exit_flag=1;
					break;
				default:
					system("CLS");
					cout<<"Press the correct keys please";
					break;
			}
			
	}while(exit_flag = 0);
	return 0;
}

int Pointme(void)
{
	D3DXVECTOR3 *firer;
	D3DXVECTOR3 *target;
	D3DXVECTOR3 VecCal;

	target = new D3DXVECTOR3;
	firer = new D3DXVECTOR3;

	target->z = 1.0f;
	firer->z = 1.0f;

	cout<<"Start by entering the points one by one"<<endl;
	
	cout<<"Begin with V1.x"<<endl;
	cin>>target->x;
	system("CLS");

	cout<<"Enter the next V1.y point"<<endl;
	cin>>target->y;
	system("CLS");


	cout<<"Enter the firer's 3D coordinates"<<endl;

	cout<<"Again start with the Firer X"<<endl;
	cin>>firer->x;
	system("CLS");

	cout<<"Now the Firer Y value"<<endl;
	cin>>firer->y;
	system("CLS");

	cout<<"Your previous entries were"<<"("<<target->x<<", "<<target->y<<", "<<target->z<<")"<<endl;
	
	cout<<"Your second entry was"<<"("<<firer->x<<", "<<firer->y<<", "<<firer->z<<")"<<endl;
	
	cout<<"Your X product is:"<<endl;
	
	cout<<"("<<VecCal.x<<", "<<VecCal.y<<", "<<VecCal.z<<")"<<endl;
	VecCal = TargetVector(target, firer);
	Sleep(5000);
	cout<<"Main Menu loading.."<<endl;
	system("CLS");
	return 0;
}

D3DXVECTOR3 TargetVector(D3DXVECTOR3 *target, D3DXVECTOR3 *firer)
{
	D3DXVECTOR3 MVector;

	D3DXVec3Subtract(&MVector, target, firer);

	D3DXVec3Normalize(&MVector, &MVector);

	return MVector;
}


bool checkme(void)
{
	bool ischecked = true;
	if (cin.fail())
	{
		cout<<"Sorry but that isn't a number so it isn't allowed."<< endl;
		cin.clear();
		cin.sync();
		system("CLS");
		ischecked = false;
	}
	return ischecked;
}





Testing: X = 1 Y = 1 , X = 1 ,Y = 1

Your X product is:
(-1.07374e+008, -1.07374e+008, -1.07374e+008)


Testing X = 4, Y = 4, X = 4, Y = 4

Your X product is:
(-1.07374e+008, -1.07374e+008, -1.07374e+008)


The value is supposed to show the X product that was calculated using the D3DXVECTOR3 Function

Can anyone shed some light on this?
You are printing the value before calculating it.
Also the computation is a subtraction, not product.


1
2
system("CLS"):
D3DXVECTOR3 *target = new D3DXVECTOR3;
Mis antenitas de vinil están detectando la presencia del enemigo
Ah so that would explain why the value was -1.07374e+008, but where would that piece of code go? after where the VecCal.x?
Topic archived. No new replies allowed.