View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002858 | FreeCAD | Bug | public | 2017-01-15 13:17 | 2017-01-22 14:33 |
Reporter | wandererfan | Assigned To | wmayer | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | all | ||||
Product Version | 0.17 | ||||
Fixed in Version | 0.17 | ||||
Summary | 0002858: Vector2d Equality Incorrect | ||||
Description | The equality operator (==) for Base::Vector2d is incorrect. It uses integer test on floating point operands: @@ -198,7 +197,8 @@ inline Vector2d& Vector2d::operator= (const Vector2d &rclVct) inline bool Vector2d::operator== (const Vector2d &rclVct) const { - return (x == rclVct.x) && (y == rclVct.y); + return (fabs (x - rclVct.x) <= FLT_EPSILON) && + (fabs (y - rclVct.y) <= FLT_EPSILON); } | ||||
Tags | No tags attached. | ||||
FreeCAD Information | |||||
|
> It uses integer test on floating point operands Why should this be an integer test? It's also valid to check for floating points for equality. However, it's true that for floating point numbers eventual round-off errors should be taken into account. Now, since Vector2d uses doubles it's better to use DBL_EPSILON for comparison. |
FreeCAD: master 6e7c4915 2017-01-15 16:34:14 Details Diff |
fixes 0002858: Vector2d Equality Incorrect |
Affected Issues 0002858 |
|
mod - src/Base/Tools2D.h | Diff File | ||
mod - src/Base/Vector3D.h | Diff File | ||
FreeCAD: master 66b91b1c 2017-01-22 14:33:26 Details Diff |
partially revert changes of issue 0002858 and add IsEqual method |
Affected Issues 0002858 |
|
mod - src/Base/Tools2D.h | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-01-15 13:17 | wandererfan | New Issue | |
2017-01-15 15:31 | wmayer | Note Added: 0007798 | |
2017-01-15 15:34 | wmayer | Changeset attached | => FreeCAD Master master 6e7c4915 |
2017-01-15 15:34 | wmayer | Assigned To | => wmayer |
2017-01-15 15:34 | wmayer | Status | new => closed |
2017-01-15 15:34 | wmayer | Resolution | open => fixed |
2017-01-15 15:35 | wmayer | Fixed in Version | => 0.17 |
2017-01-22 14:33 | wmayer | Changeset attached | => FreeCAD Master master 66b91b1c |