Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))
From: claude uq (c.dietrich_at_uq.edu.au)
Date: 12/17/03
- Next message: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Previous message: Malcolm: "C Overflow and MSVC++"
- Next in thread: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Robert Stankowic: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Anthony Borla: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Richard Heathfield: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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;
system("pause");
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.
- Next message: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Previous message: Malcolm: "C Overflow and MSVC++"
- Next in thread: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: claude uq: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Robert Stankowic: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Anthony Borla: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Reply: Richard Heathfield: "Re: Visual C++ strange arithmetic (hope such arithmetic does not apply to Microsoft accountancy;-))"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|