Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))

From: claude uq (
Date: 12/17/03

Date: Wed, 17 Dec 2003 14:55:11 +1000

What could be a simpler snippet than this

#include <iostream>
using std::cout;
using std::endl;

int main() {

 long nx = 200L;
 long ny = 300L;
 long gridSize = 0L;
 long var = 0L;

 gridSize = nx*ny;
 var = gridSize*gridSize;
 cout<<gridSize<<" "<<var<<endl;

 return 0;

When executed, the above streams out 60000 for gridSize and -694967296 for
var !!!

Tried on a few machine, still same. What's going on here.