Changeset 49056 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 2, 2009, 4:35:31 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r49030 r49056 1 2009-10-02 Jonni Rainisto <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 Math.random() gives too low values on Win32 when _CRT_RAND_S is not defined 6 https://bugs.webkit.org/show_bug.cgi?id=29956 7 8 * wtf/RandomNumber.cpp: 9 (WTF::randomNumber): Added PLATFORM(WIN_OS) to handle 15bit rand() 10 1 11 2009-10-02 Geoffrey Garen <[email protected]> 2 12 -
trunk/JavaScriptCore/wtf/RandomNumber.cpp
r45865 r49056 83 83 #elif PLATFORM(WINCE) 84 84 return genrand_res53(); 85 #elif PLATFORM(WIN_OS) 86 uint32_t part1 = rand() & (RAND_MAX - 1); 87 uint32_t part2 = rand() & (RAND_MAX - 1); 88 uint32_t part3 = rand() & (RAND_MAX - 1); 89 uint32_t part4 = rand() & (RAND_MAX - 1); 90 // rand only provides 15 bits on Win32 91 uint64_t fullRandom = part1; 92 fullRandom <<= 15; 93 fullRandom |= part2; 94 fullRandom <<= 15; 95 fullRandom |= part3; 96 fullRandom <<= 15; 97 fullRandom |= part4; 98 99 // Mask off the low 53bits 100 fullRandom &= (1LL << 53) - 1; 101 return static_cast<double>(fullRandom)/static_cast<double>(1LL << 53); 85 102 #else 86 103 uint32_t part1 = rand() & (RAND_MAX - 1);
Note:
See TracChangeset
for help on using the changeset viewer.