Declaring variables in c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey22
    New Member
    • Feb 2007
    • 105

    Declaring variables in c++

    Hi all,

    I have a value calculated from a member function of a class and assigned it to variable in my project say

    unsigned short int var1=a.inf( ); since inf ( ) returns unsigned short int

    Now I have to use this value var1 to calculate another variable var2 which should be uint64 as I have to pass this var2 to another function.

    In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.Could you please suggest me if there is any way to do this without typecasting and not losing any data.

    Thanks.
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi Perhaps you could post the code where you use a typecast and loose the data.

    Comment

    • mickey22
      New Member
      • Feb 2007
      • 105

      #3
      I am sorry I did not get you what u meant.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        Originally posted by mickey22
        Hi all,

        I have a value calculated from a member function of a class and assigned it to variable in my project say

        unsigned short int var1=a.inf( ); since inf ( ) returns unsigned short int

        Now I have to use this value var1 to calculate another variable var2 which should be uint64 as I have to pass this var2 to another function.

        In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.Could you please suggest me if there is any way to do this without typecasting and not losing any data.

        Thanks.
        You say:

        In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.

        and willakawill says:

        Perhaps you could post the code where you use a typecast and loose the data?

        What part of that does not make sense?

        Comment

        Working...