I have code which calls a lot of

```
int myNumber = (int)(floatNumber);

```

which takes up, in total, around 10% of my CPU time (according to profiler). While I could leave it at that, I wonder if there are faster options, so I tried searching around, and stumbled upon

> 
> <http://devmaster.net/forums/topic/7804-fast-int-float-conversion-routines/>
> <http://stereopsis.com/FPU.html>
> 
> 
> 

I tried implementing the Real2Int() function given there, but it gives me wrong results, and runs slower. Now I wonder, are there faster implementations to floor double / float values to integers, or is the SSE2 version as fast as it gets? The pages I found date back a bit, so it might just be outdated, and newer STL is faster at this.

The current implementation does:

```
013B1030  call        _ftol2_sse (13B19A0h)

013B19A0  cmp         dword ptr [___sse2_available (13B3378h)],0  
013B19A7  je          _ftol2 (13B19D6h)  
013B19A9  push        ebp  
013B19AA  mov         ebp,esp  
013B19AC  sub         esp,8  
013B19AF  and         esp,0FFFFFFF8h  
013B19B2  fstp        qword ptr [esp]  
013B19B5  cvttsd2si   eax,mmword ptr [esp]  
013B19BA  leave  
013B19BB  ret  

```

Related questions I found:

> 
> [Fast float to int conversion and floating point precision on ARM (iPhone 3GS/4)](https://stackoverflow.com/questions/3483670/fast-float-to-int-conversion-and-floating-point-precision-on-arm-iphone-3gs-4)
> 
> 
> [What is the fastest way to convert float to int on x86](https://stackoverflow.com/questions/78619/what-is-the-fastest-way-to-convert-float-to-int-on-x86)
> 
> 
> 

Since both are old, or are ARM based, I wonder if there are current ways to do this. Note that it says the best conversion is one that doesn't happen, but I need to have it, so that will not be possible.