|
|
|
|
|
|
d*z 发帖数: 150 | | h****i 发帖数: 254 | 2 haha, try this:
int floor(float f) {
int fi = *((int*)(&f));
int exp = ((fi<<1)-0x7f000000)>>24;
int val = fi&0x007fffff|0x00800000;
int shift = exp - 23;
if(f>=0) {
if(shift>0) return val<
else return val>>(-shift);
}
else {
if(shift>0) return -(val<
else {
shift = -shift;
int odds = val&(~((-1)<
if(odds==0) return -(val>>shift);
else return -1-(val>>shift);
}
}
}
things? |
|
|
|
|
|
|