From 654eee910d2f139fe84fcc05502d6aedc019cfa4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 23 Apr 2015 20:24:27 -0500 Subject: [PATCH] Don't compare floating point numbers directly, but via std::fabs. --- examples/step-42/step-42.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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); } } -- 2.39.5