dff data types in c++

R

rupika

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[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][c].nbr[j][k] = -1;
}
sen[a][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[j][k].n = gen();

AM(t);
}
 
F

Francesco S. Carta

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[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][c].nbr[j][k] = -1;
}
sen[a][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[j][k].n = gen();

AM(t);
}


http://www.parashift.com/c++-faq-lite

Finger on faq-5.8

Hope that helps - well, not this very time, I suppose, maybe the next.

Sorry.
 
R

rupika

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[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][c].nbr[j][k] = -1;
                  }
             sen[a][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[j][k].n = gen();

                   AM(t);
        }

http://www.parashift.com/c++-faq-lite

Finger on faq-5.8

Hope that helps - well, not this very time, I suppose, maybe the next.

Sorry.


Hs
thanx for the reply but i didn gt it there.
Its like should i make the chnges ever where in the code where i hav
used
nbr
?
wat about the part where nbr is multiplied or compared with other data
type int?
plz help
thank you
 
Ö

Öö Tiib

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[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][c].nbr[j][k] = -1;
                  }
             sen[a][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[j][k].n = gen();
                   AM(t);
        }

Finger on faq-5.8

Hope that helps - well, not this very time, I suppose, maybe the next.

Hs
thanx for the reply but i didn gt it there.
Its like should i make the chnges ever where in the code where i hav
used
 nbr
?
wat about the part where nbr is multiplied or compared with other data
type int?
plz help
thank you


You have to (so urgently) deal with performance optimizations/
refactorings without knowledge how int and short work together? Sounds
like either nonsense or homework. If it is nonsense then tell to
people who asked it from you that you are not qualified enough. If it
is homework then do it yourself? Search for "integral promotions" and
"implicit conversions" in documentation or net.
 
R

red floyd

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[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][c].nbr[j][k] = -1;
                  }
             sen[a][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[j][k].n = gen();
                   AM(t);
        }
http://www.parashift.com/c++-faq-lite
Finger on faq-5.8
Hope that helps - well, not this very time, I suppose, maybe the next..
Sorry.

Hs
thanx for the reply but i didn gt it there.
Its like should i make the chnges ever where in the code where i hav
used
 nbr
?
wat about the part where nbr is multiplied or compared with other data
type int?
plz help
thank you

You have to (so urgently) deal with performance optimizations/
refactorings without knowledge how int and short work together? Sounds
like either nonsense or homework. If it is nonsense then tell to
people who asked it from you that you are not qualified enough. If it
is homework then do it yourself? Search for "integral promotions" and
"implicit conversions" in documentation or net.



Hey, come on. He's changing the type of "nbr", which is int[3][3][3],
to short[3][3][3]. Those 54 bytes are vital!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top