Random number generators discussion

Random number generators | www.agner.org

 
thread Fast Float Conversion - Sandeep - 2004-08-30
last reply Fast Float Conversion - Agner - 2004-08-31
 
Fast Float Conversion
Author:  Date: 2004-08-30 05:38
The method for Int to FastFloat conversion is working fine. Can u tell me is there any similar methad for float to Int conversion.

union {
double randp1;
uint32 randbits[2];};
randbits[0] = x << 20;
randbits[1] = (x >> 12) | 0x3FF00000;
return randp1 - 1.0;}


Any pointer to this will be apreciated.

Regards
Sandeep H.R

   
Fast Float Conversion
Author: Agner Date: 2004-08-31 11:39
The fastest way to convert a float to an int is the Round function in my library of assembly functions. You can download it from www.agner.org/assem/asmlib.zip
There are different versions for different compilers under Windows and Linux. The number is rounded rather than truncated.