Displaying 1 result from an estimated 1 matches for "3,32768".
2012 Aug 06
4
[LLVMdev] Casting from float to unsigned char - incorrect output?
...m to produce the correct output for negative
numbers. When I run the following code, I get -1 instead of 255 (which is
produced by compiling natively with gcc).
int trunc(float c);
int main() {
printf("%d\n", trunc(-1.0));
}
I am running the mips code on a PISA simulator (SimpleScalar's Simple-Sim
3.0) instead of a MIPS IV simulator, so there is a little bit of
translation occurring before I can simulate it; here is the revised code:
trunc:
cvt.w.s $f0, $f12
mfc1 $2, $f0
jr $ra
nop
the cvt.w.s function in PISA MIPS is rounding towards zero, so it shoul...