Displaying 2 results from an estimated 2 matches for "a78459c6".
2012 Aug 06
0
[LLVMdev] Casting from float to unsigned char - incorrect output?
...n", trunc(-1.0));
>> > }
>>
>> That code has undefined behavior; see 6.3.1.4p1 in C99
>>
>> -Eli
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120806/a78459c6/attachment.html>
2012 Aug 06
4
[LLVMdev] Casting from float to unsigned char - incorrect output?
I am compiling the following code for the MIPS architecture:
unsigned char trunc(float f) {
return (unsigned char) f;
}
and it produces the following assembly (directives removed for convenience:
trunc:
trunc.w.s $f0, $f12
mfc1 $2, $f0
jr $ra
nop
However, this does not seem to produce the correct output for negative
numbers. When I run the following code, I get