Skip to content

Commit 122f0bb

Browse files
committed
[gpad] avoid potential float precision lost in PaintHatches
Use integer conversion once and then just check boundary with ymin
1 parent 22411ce commit 122f0bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

graf2d/gpad/src/TPad.cxx

+5-3
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ Int_t TPad::ClipPolygon(Int_t n, Double_t *x, Double_t *y, Int_t nn, Double_t *x
951951
{
952952
if (n <= 0)
953953
return 0;
954-
954+
955955
Int_t nc, nc2;
956956
Double_t x1, y1, x2, y2, slope; // Segment to be clipped
957957

@@ -4219,9 +4219,11 @@ void TPad::PaintHatches(Double_t dy, Double_t angle,
42194219
if (yrot > ymax) ymax = yrot;
42204220
if (yrot < ymin) ymin = yrot;
42214221
}
4222-
ymax = (Double_t)((Int_t)(ymax/dy))*dy;
42234222

4224-
for (ycur=ymax; ycur>=ymin; ycur=ycur-dy) {
4223+
Int_t yindx = (Int_t) (ymax/dy);
4224+
4225+
while (dy * yindx >= ymin) {
4226+
ycur = dy * yindx--;
42254227
nbi = 0;
42264228
for (i=2; i<=nn+1; i++) {
42274229
i2 = i;

0 commit comments

Comments
 (0)