From: rupika on
Hi can any one tell me if diff data types like int and short be
multiplied
in code.
i HAVE TO REDUCE THE MEMORY SIZE SO CHANGE DATATYPE OF nbr TO SHORT
WHERE ELSE DO I MAKE CHANGES.ALSO IF DATA TYPE OF NBR IS CHNGED CAN
IT
BE MUTLIPLIED WITH SEN AND N WITHOUT CHANGING DERE DATATYPE
HELP ITS URGENT
THANK U
struct Node
{
int n;
int nbr[3][3][3];
};

Node sen[SIZE][SIZE][SIZE];
......
..
..
..
..
..int print(int nbr[][3][3])
{
int max = 0;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
{
int m = nbr[i][j][k];
if (m > max )
max = m;
}
return max;
}

..
..
..
int main()
{
srand(time(0));
for (int a = 0; a < SIZE; a++)
for (int b = 0; b < SIZE; b++)
for (int c = 0; c < SIZE; c++)
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
{
sen[a][b][c].nbr[i][j][k] = -1;
}
sen[a][b][c].nbr[1][1][1] = 1;
}
for (int t = 0; t < TIME; t++) //time ticks
{
for (int i = 0; i < SIZE; i++)
for (int j = 0; j < SIZE; j++)
for (int k = 0; k < SIZE; k++)
sen[i][j][k].n = gen();
AM(t);
}
From: Fred Nurk on
rupika wrote:

> Hi can any one tell me if diff data types like int and short be
> multiplied in code.

Yes - just store it in a data type that can hold large enough numbers for
you. For example, int, long int, or long long but most likely not short
int.

> i HAVE TO REDUCE THE MEMORY SIZE SO CHANGE DATATYPE OF nbr TO SHORT
> WHERE ELSE DO I MAKE CHANGES.ALSO IF DATA TYPE OF NBR IS CHNGED CAN IT
> BE MUTLIPLIED WITH SEN AND N WITHOUT CHANGING DERE DATATYPE HELP ITS
> URGENT
> <snip>

You should change it inside the struct definition and as a function
parameter. I don't think anything else needs to change.

Fred Nurk