Strange that D is printing large values as zero. Any mistake in my code?

Adam D. Ruppe destructionator at gmail.com
Thu Feb 14 07:49:53 PST 2013


> const long DIM = 1024*1024*1024*1024*4;

Those are all int (32 bit) literals so it is prolly wrapping 
around the intermediates before it actually assigns to DIM.

If you used 1024L it should be better, by making the right hand 
side 64 bit too.

It is similar to

float x = 1 / 2; // x == 0 because the right hand side is done as 
ints

float x = 1.0 / 2; // now x == 0.5


More information about the Digitalmars-d-learn mailing list