none
can not understand why is "Convert to Int64" is use RRS feed

Answers

  • It is depends upon the value u want to convert. The maximum value that you can convert to int16 is 32767.If the number greater than this value it will throw an exception.But if you use int64 you can convert even too large numbers.max . 9,223,372,036,854,775,807
    See this url for more details :http://msdn.microsoft.com/en-us/library/y9www74y.aspx
    • Marked as answer by YiChun Chen Thursday, December 3, 2009 6:53 AM
    Wednesday, December 2, 2009 5:29 PM
  • Hi kunalloveindia,

    Welcome to msdn forums.

    Regarding your question. Since Int64 can handle up to 8 bytes of data, it can accept Int16, Int32 and Int64 values in any format and convert it for you.
    Alternatively, if you tries to convert an Int64 value and store it in Int32 or Int16. It will fail, as none of them can hold a 8 byte value.

    Hope i have made myself clear.

    As an added note,
     
    - If the machine is 32 bit, the 64 operations will take more time.


    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Marked as answer by YiChun Chen Thursday, December 3, 2009 6:53 AM
    Wednesday, December 2, 2009 5:43 PM
  • Hi Kunalloveindia,

    Thank you for your post.

    For your better understanding on Int16 structure, Int32 structure and Int64 structure, here're some helpful documents that refer to them.
    Please check:
    Int16 Structure
    http://msdn.microsoft.com/en-us/library/system.int16.aspx
    Int32 structure
    http://msdn.microsoft.com/en-us/library/system.int32.aspx
    Int64 Structure
    http://msdn.microsoft.com/en-us/library/system.int64.aspx
    Converting to int16, int32, int64 - how do you know which one to choose
    http://stackoverflow.com/questions/270263/converting-to-int16-int32-int64-how-do-you-know-which-one-to-choose

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen

    (This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.)
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by YiChun Chen Thursday, December 3, 2009 7:01 AM Add Int32
    • Marked as answer by YiChun Chen Friday, December 4, 2009 3:58 AM
    Thursday, December 3, 2009 6:59 AM

All replies

  • It is depends upon the value u want to convert. The maximum value that you can convert to int16 is 32767.If the number greater than this value it will throw an exception.But if you use int64 you can convert even too large numbers.max . 9,223,372,036,854,775,807
    See this url for more details :http://msdn.microsoft.com/en-us/library/y9www74y.aspx
    • Marked as answer by YiChun Chen Thursday, December 3, 2009 6:53 AM
    Wednesday, December 2, 2009 5:29 PM
  • Hi kunalloveindia,

    Welcome to msdn forums.

    Regarding your question. Since Int64 can handle up to 8 bytes of data, it can accept Int16, Int32 and Int64 values in any format and convert it for you.
    Alternatively, if you tries to convert an Int64 value and store it in Int32 or Int16. It will fail, as none of them can hold a 8 byte value.

    Hope i have made myself clear.

    As an added note,
     
    - If the machine is 32 bit, the 64 operations will take more time.


    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Marked as answer by YiChun Chen Thursday, December 3, 2009 6:53 AM
    Wednesday, December 2, 2009 5:43 PM
  • Hi Kunalloveindia,

    Thank you for your post.

    For your better understanding on Int16 structure, Int32 structure and Int64 structure, here're some helpful documents that refer to them.
    Please check:
    Int16 Structure
    http://msdn.microsoft.com/en-us/library/system.int16.aspx
    Int32 structure
    http://msdn.microsoft.com/en-us/library/system.int32.aspx
    Int64 Structure
    http://msdn.microsoft.com/en-us/library/system.int64.aspx
    Converting to int16, int32, int64 - how do you know which one to choose
    http://stackoverflow.com/questions/270263/converting-to-int16-int32-int64-how-do-you-know-which-one-to-choose

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen

    (This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.)
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by YiChun Chen Thursday, December 3, 2009 7:01 AM Add Int32
    • Marked as answer by YiChun Chen Friday, December 4, 2009 3:58 AM
    Thursday, December 3, 2009 6:59 AM