隐蔽的数据溢出问题

unsigned int blocks = 20000;
unsigned int blocksize = 5000;
int64_t totalsize;

// overflow, error!!
totalsize = blocks * blocksize;

// mandatory type transfer, right!
totalsize = (int64_t)blocks * blocksize;

posted @ 2010-01-22 09:04  Java天堂  阅读(127)  评论(0)    收藏  举报