From: Wolfgang Bangerth Date: Fri, 24 Apr 2015 01:24:27 +0000 (-0500) Subject: Don't compare floating point numbers directly, but via std::fabs. X-Git-Tag: v8.3.0-rc1~216^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F869%2Fhead;p=dealii.git Don't compare floating point numbers directly, but via std::fabs. --- diff --git a/examples/step-42/step-42.cc b/examples/step-42/step-42.cc index 8567b2429f..1453429020 100644 --- a/examples/step-42/step-42.cc +++ b/examples/step-42/step-42.cc @@ -952,14 +952,14 @@ namespace Step42 ++face_no) if (cell->face(face_no)->at_boundary()) { - if (cell->face(face_no)->center()[2] == p2(2)) + if (std::fabs(cell->face(face_no)->center()[2] - p2[2]) < 1e-12) cell->face(face_no)->set_boundary_id(1); - if (cell->face(face_no)->center()[0] == p1(0) - || cell->face(face_no)->center()[0] == p2(0) - || cell->face(face_no)->center()[1] == p1(1) - || cell->face(face_no)->center()[1] == p2(1)) + if (std::fabs(cell->face(face_no)->center()[0] - p1[0]) < 1e-12 + || std::fabs(cell->face(face_no)->center()[0] - p2[0]) < 1e-12 + || std::fabs(cell->face(face_no)->center()[1] - p1[1]) < 1e-12 + || std::fabs(cell->face(face_no)->center()[1] - p2[1]) < 1e-12) cell->face(face_no)->set_boundary_id(8); - if (cell->face(face_no)->center()[2] == p1(2)) + if (std::fabs(cell->face(face_no)->center()[2] - p1[2]) < 1e-12) cell->face(face_no)->set_boundary_id(6); } }