Or just reversed the endianness of this binary_million.

On Wed, Jan 12, 2011 at 3:23 PM, Alexandre Rames
<[email protected]>wrote:

> Are you cross compiling? I don't understand how the double binary_million
> value can be reversed.
>
> Try replacing
> const double binary_million = 1048576.0;
> with some manual 64bit correct (for your system) floating point value (cast
> a known 64bit value to a double) instead.
> Then check again your math.random and check with gdb that you are actually
> going through this function.
>
>
> On Wed, Jan 12, 2011 at 3:13 PM, Guillaume <[email protected]> wrote:
>
>> Hi.
>>
>> Thx for your answer.
>>
>> I'm afraid I get : 5.333806864e-315 with step 1.
>> ##
>> Object* V8::FillHeapNumberWithRandom(Object* heap_number) {
>>  // uint64_t random_bits = Random();
>>  // Make a double* from address (heap_number + sizeof(double)).
>>  double_int_union* r = reinterpret_cast<double_int_union*>(
>>      reinterpret_cast<char*>(heap_number) +
>>      HeapNumber::kValueOffset - kHeapObjectTag);
>>  // Convert 32 random bits to 0.(32 random bits) in a double
>>  // by computing:
>>  // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
>>  const double binary_million = 1048576.0;
>>   r->double_value = binary_million;
>>   //r->uint64_t_value |=  random_bits;
>>   //r->double_value -= binary_million;
>>
>>   return heap_number;
>> }
>> ##
>>
>> I try step 2 for fun, and I get 1.7422461335011523e+41.
>>
>> Guillaume
>>
>> --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>>
>
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to