Skip to content

Commit 488e6a2

Browse files
committed
Fix floating-point in affine transformation on x86 vs v86-64
1 parent 2188187 commit 488e6a2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/_path.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,24 @@ _path_module::affine_transform(const Py::Tuple& args)
11591159
size_t stride1 = PyArray_STRIDE(vertices, 1);
11601160
double x;
11611161
double y;
1162+
volatile double t0;
1163+
volatile double t1;
1164+
volatile double t;
11621165

11631166
for (size_t i = 0; i < n; ++i)
11641167
{
11651168
x = *(double*)(vertex_in);
11661169
y = *(double*)(vertex_in + stride1);
11671170

1168-
*vertex_out++ = a * x + c * y + e;
1169-
*vertex_out++ = b * x + d * y + f;
1171+
t0 = a * x;
1172+
t1 = c * y;
1173+
t = t0 + t1 + e;
1174+
*(vertex_out++) = t;
1175+
1176+
t0 = b * x;
1177+
t1 = d * y;
1178+
t = t0 + t1 + f;
1179+
*(vertex_out++) = t;
11701180

11711181
vertex_in += stride0;
11721182
}

0 commit comments

Comments
 (0)