Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the MinValue for an Int32 struct in C# have two minus signs infront of it?

When I right-click int in my code and select "Go To Definition," Visual Studio opens a file titled "Int32 [from metadata]". This file includes the following line:

public const Int32 MinValue = --2147483648;

What is the meaning of the double -- sign?

enter image description here


I am running Visual Studio 15.8.4. Based on information in the comments, this is not reproducible on all versions of Visual Studio 2017.

like image 419
psj01 Avatar asked Sep 11 '18 20:09

psj01


1 Answers

vcsjones pointed to the newly created bug report and this post appeared there:

CyrusNajmabadi commented

This is probably a bug i introduced when i fixed up how literals were converted to syntax nodes. There was probably some special casing here that added a - sign. And once the underlying helper was fixed we got double negation.

like image 116
bolov Avatar answered Oct 03 '22 16:10

bolov