dff data types in c++

Discussion in 'C++' started by rupika, Jun 30, 2010.

  1. rupika

    rupika Guest

    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);
    }
     
    rupika, Jun 30, 2010
    #1
    1. Advertising

  2. rupika <>, on 30/06/2010 11:02:06, wrote:

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

    --
    FSC
    http://userscripts.org/scripts/show/59948
     
    Francesco S. Carta, Jun 30, 2010
    #2
    1. Advertising

  3. rupika

    rupika Guest

    On Jun 30, 11:12 pm, "Francesco S. Carta" <> wrote:
    > rupika <>, on 30/06/2010 11:02:06, wrote:
    >
    >
    >
    >
    >
    > > 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.
    >
    > --
    > FSChttp://userscripts.org/scripts/show/59948


    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
     
    rupika, Jun 30, 2010
    #3
  4. rupika

    Öö Tiib Guest

    On 30 juuni, 21:43, rupika <> wrote:
    > On Jun 30, 11:12 pm, "Francesco S. Carta" <> wrote:
    >
    >
    >
    > > rupika <>, on 30/06/2010 11:02:06, wrote:

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

    >
    > > --
    > > FSChttp://userscripts.org/scripts/show/59948

    >
    > 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.
     
    Öö Tiib, Jun 30, 2010
    #4
  5. rupika

    red floyd Guest

    On Jun 30, 12:39 pm, Öö Tiib <> wrote:
    > On 30 juuni, 21:43, rupika <> wrote:
    >
    >
    >
    > > On Jun 30, 11:12 pm, "Francesco S. Carta" <> wrote:

    >
    > > > rupika <>, on 30/06/2010 11:02:06, wrote:

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

    >
    > > > --
    > > > FSChttp://userscripts.org/scripts/show/59948

    >
    > > 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!!!
     
    red floyd, Jun 30, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sathyaish
    Replies:
    2
    Views:
    594
    Sathyaish
    May 22, 2005
  2. Davy
    Replies:
    2
    Views:
    451
    Thomas Stanka
    Mar 28, 2006
  3. ramu
    Replies:
    2
    Views:
    330
    rlblaster
    Feb 20, 2006
  4. Gary Roach
    Replies:
    0
    Views:
    114
    Gary Roach
    Sep 1, 2013
  5. Fábio Santos
    Replies:
    0
    Views:
    122
    Fábio Santos
    Sep 4, 2013
Loading...

Share This Page