Author: [EMAIL PROTECTED]
Date: Thu Nov 20 03:33:50 2008
New Revision: 805

Modified:
    branches/bleeding_edge/src/runtime.cc

Log:
Explicitly change a floating point division with a constant into a
multiplication by its inverse.

In optimized builds GCC does this on its own, but this may be useful
when using other compilers.
Review URL: http://codereview.chromium.org/11524

Modified: branches/bleeding_edge/src/runtime.cc
==============================================================================
--- branches/bleeding_edge/src/runtime.cc       (original)
+++ branches/bleeding_edge/src/runtime.cc       Thu Nov 20 03:33:50 2008
@@ -3163,9 +3163,9 @@
    // double in the range [0, RAND_MAX + 1) obtained by adding the
    // high-order bits in the range [0, RAND_MAX] with the low-order
    // bits in the range [0, 1).
-  double lo = static_cast<double>(random()) / (RAND_MAX + 1.0);
+  double lo = static_cast<double>(random()) * (1.0 / (RAND_MAX + 1.0));
    double hi = static_cast<double>(random());
-  double result = (hi + lo) / (RAND_MAX + 1.0);
+  double result = (hi + lo) * (1.0 / (RAND_MAX + 1.0));
    ASSERT(result >= 0 && result < 1);
    return Heap::AllocateHeapNumber(result);
  }

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

Reply via email to