Click here to Skip to main content
15,904,655 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Tiny Quiz Pin
Colin Mullikin15-Oct-13 3:42
professionalColin Mullikin15-Oct-13 3:42 
GeneralRe: Tiny Quiz Pin
glennPattonWork315-Oct-13 3:46
professionalglennPattonWork315-Oct-13 3:46 
GeneralRe: Tiny Quiz Pin
Richard Deeming15-Oct-13 3:09
mveRichard Deeming15-Oct-13 3:09 
GeneralRe: Tiny Quiz Pin
Rage15-Oct-13 3:24
professionalRage15-Oct-13 3:24 
GeneralRe: Tiny Quiz Pin
Colin Mullikin15-Oct-13 3:44
professionalColin Mullikin15-Oct-13 3:44 
GeneralRe: Tiny Quiz Pin
Richard Deeming15-Oct-13 4:01
mveRichard Deeming15-Oct-13 4:01 
GeneralRe: Tiny Quiz Pin
Rage15-Oct-13 4:02
professionalRage15-Oct-13 4:02 
AnswerRe: Tiny Quiz Pin
Super Lloyd15-Oct-13 2:51
Super Lloyd15-Oct-13 2:51 
Simple! Big Grin | :-D

C#
int bM = int.MaxValue, bm = int.MinValue;
Console.WriteLine("Min/Max: {0}/{1}, -Min/-Max: {2}/{3}", bm, bM, -bm, -bM);


will print
VB
Min/Max: -2147483648/2147483647, -Min/-Max: -2147483648/-2147483647


As you can see, int.Min == -int.Min (because there is just not enough positive integer!! Laugh | :laugh: )

Further, as far as int arithmetic is concerned:
1080000000 x2 = -2134967296


Morale of the story?
Don't overflow!
use checked() block? as in:
C#
int bM = int.MaxValue, bm = int.MinValue;
int bm2;
checked
{
    bm2 = -bm;
}

My programming get away... The Blog...
DirectX for WinRT/C# since 2013!
Taking over the world since 1371!


modified 15-Oct-13 8:58am.

GeneralRe: Tiny Quiz Pin
Rage15-Oct-13 2:53
professionalRage15-Oct-13 2:53 
GeneralRe: Tiny Quiz Pin
harold aptroot15-Oct-13 2:56
harold aptroot15-Oct-13 2:56 
GeneralRe: Tiny Quiz Pin
gardnerp15-Oct-13 3:24
gardnerp15-Oct-13 3:24 
QuestionConfuse-a-cat Pin
hairy_hats15-Oct-13 0:55
hairy_hats15-Oct-13 0:55 
AnswerRe: Confuse-a-cat Pin
Septimus Hedgehog15-Oct-13 1:02
Septimus Hedgehog15-Oct-13 1:02 
AnswerRe: Confuse-a-cat Pin
dxs75315-Oct-13 1:14
dxs75315-Oct-13 1:14 
AnswerRe: Confuse-a-cat Pin
User 171649215-Oct-13 1:19
professionalUser 171649215-Oct-13 1:19 
GeneralRe: Confuse-a-cat Pin
Rage15-Oct-13 1:31
professionalRage15-Oct-13 1:31 
GeneralRe: Confuse-a-cat Pin
OriginalGriff15-Oct-13 1:50
mveOriginalGriff15-Oct-13 1:50 
GeneralRe: Confuse-a-cat Pin
Dan Neely15-Oct-13 2:50
Dan Neely15-Oct-13 2:50 
GeneralRe: Confuse-a-cat Pin
User 171649215-Oct-13 1:59
professionalUser 171649215-Oct-13 1:59 
GeneralRe: Confuse-a-cat Pin
Rage15-Oct-13 2:02
professionalRage15-Oct-13 2:02 
GeneralRe: Confuse-a-cat Pin
Keith Barrow15-Oct-13 2:10
professionalKeith Barrow15-Oct-13 2:10 
GeneralRe: Confuse-a-cat Pin
User 171649215-Oct-13 2:15
professionalUser 171649215-Oct-13 2:15 
AnswerRe: Confuse-a-cat Pin
Richard MacCutchan15-Oct-13 3:22
mveRichard MacCutchan15-Oct-13 3:22 
AnswerRe: Confuse-a-cat Pin
Mike Hankey15-Oct-13 3:29
mveMike Hankey15-Oct-13 3:29 
GeneralMMQOTD???? Pin
Johnny J.15-Oct-13 0:42
professionalJohnny J.15-Oct-13 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.