Lukas Domagala

  Home  |   Contact  |   Syndication    |   Login
  6 Posts | 0 Stories | 7 Comments | 0 Trackbacks

News

I have joined Anti-IF Campaign
Subscribe in a reader

Tag Cloud


Archives

Post Categories

Ok, so do you have any idea what happens when you evaluate this?

printfn "%d" -Int32.MinValue;;

Well I would have guessed I´d get Int32.MaxValue, but well I was wrong. Actually it overflows again and prints Int32.MinValue. Interesting behavior that drove me mad while i was trying to implement Alpha-Beta pruning.

There is a simple reason this happens: “The Int32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647.” – MSDN

Ok so there is no positive version of Int32.MinValue and we Overflow. The C# compiler wont even compile code that has –Int32.MinValue anywhere. I guess its smarter then me, because i would have been fine with an Int32 that is actually intuitive to use and has one less number;). Ah well I guess I am just to used to using non-overflowing Ruby numbers…

 

Technorati Tags: ,
posted on Thursday, June 18, 2009 8:47 PM