0x80000000 == 2147483648 in C # but not in VB.NET

In C #:

0x80000000==2147483648 //outputs True

In VB.NET:

&H80000000=2147483648 'outputs False

How is this possible?

+4
source share
3 answers

This is due to the story behind the languages.

C # always supports unsigned integers. The value you use is too large for int, so the compiler chooses the next type that can correctly represent the value. This is uint for both.

VB.NET 8 (.NET 2.0). Long 2147483648. , (. 2.4.2 ). , H80000000 Integer -2147483648 2147483648 - . , .

, VB.NET - , :)

+8

VB :

&H80000000L=2147483648

"" ( "L" ), VB H8000000 . , . & H80000000UI - (UInt32), # .

+4

, UInt32 # Int32 VB.NET.
:

10000000000000000000000000000000

UInt32 Int32 32 , Int32 , , , : 0 , 1 . , :

  • . 01111111111111111111111111111111.
  • . 2147483647.
  • 1 . 2147483648.
  • Make it negative. You get -2147483648that equal &H80000000in VB.NET.
+1
source

Source: https://habr.com/ru/post/1541958/


All Articles