Fix problems with flakes in SVG LayoutTests by reordering arithmetic.

This operation gives 4.99999952: float(25 + 200 * double(1.f*(-10.0f/100.f)))
This operation gives 5.00000000: float(25 + 200 * float(1.f*(-10.0f/100.f)))

Why 4.99999952 appear only sometimes, and only on Windows, is
not fully known. A suspect is that it's related to the 32-bit ABI which
requires use of x87 for passing floats. That combined with various
inlining decisions and context switches could possibly affect the final
value in a way that makes it seem random.

The fix in this patch is to reorder some operations. Using the example
above it will be changed to:

  float(25 + (200 * 1.f * -10.f) / 100.f)

By delaying the dangerous division, every intermediate value will
be representable by a float with no errors.

This won't solve all floating point errors but it will solve the one that causes
the most common CQ flakes.

BUG=438282

Review URL: https://codereview.chromium.org/861213003

git-svn-id: svn://svn.chromium.org/blink/trunk@188871 bbb929c8-8fbe-4397-9dbb-9b2b20218538
52 files changed
tree: 17205522a7b546947b168bd8041231edbd2ecaeb
  1. third_party/