Home > database >  Data type sizes in C and VB.NET
Data type sizes in C and VB.NET

Time:11-30

I am working on developing an application in VB.NET which uses a third party DLL for which the documentation is for C . For the data type conversions, I was using two pages:

https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/

I was looking up the size in the C page and the equivalent size for VB.NET; e.g. int is 4 bytes in C so the corresponding VB.NET would be INT32 or Integer.

However, that was giving me unexpected results.

I then noticed that C long int is given as 8 bytes with values of -2,147,483,648 to 2,147,483,647 while VB.NET long is also given as 8 bytes with a data type of INT64 but the values are shown as -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.

Also, the sizes for C int (4 bytes) and long (8 bytes) are different but the ranges are the same.

Why the two (wildly) differing ranges for an 8 byte variable? Is one of the pages wrong?

CodePudding user response:

Check this: https://docs.microsoft.com/en-gb/cpp/cpp/data-type-ranges?view=msvc-170 Long is 4 bytes. The vb.net page is correct, the C one is not.

  • Related