Newbie question here: what's the best way to truncate a float to a signed int? The fptosi instruction rounds, and the fptrunc instruction simply truncates from a large float type to a smaller float type. Mark
On Tue, Jun 3, 2008 at 11:32 AM, Mark Leone <markleone at gmail.com> wrote:> Newbie question here: what's the best way to truncate a float to a > signed int? The fptosi instruction rounds, and the fptrunc > instruction simply truncates from a large float type to a smaller > float type.fptosi is equivalent to a C cast from float to int. -Eli
On Tue, Jun 3, 2008 at 12:48 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Tue, Jun 3, 2008 at 11:32 AM, Mark Leone <markleone at gmail.com> wrote: >> Newbie question here: what's the best way to truncate a float to a >> signed int? The fptosi instruction rounds, and the fptrunc >> instruction simply truncates from a large float type to a smaller >> float type. > > fptosi is equivalent to a C cast from float to int. > > -EliThanks, I misread the assembly reference (I saw "nearest signed integer" and missed the "rounding towards zero"). - Mark
Maybe Matching Threads
- [LLVMdev] Truncate float to int?
- Misleading documentation on FP to integer conversion instructions?
- Misleading documentation on FP to integer conversion instructions?
- [cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?
- [cfe-dev] Why is #pragma STDC FENV_ACCESS not supported?