Param::Set truncates floating point numbers
Closed this issue · 2 comments
scpeters commented
Environment
- OS Version: confirmed on Ubuntu / macOS
- Source or binary build? tested on
sdf13
branch
Description
- Expected behavior: when passing a value containing floating point values to
Param::Set
, all the precision should be preserved - Actual behavior: some precision is lost when using
Param::Set
Steps to reproduce
- Check out and build f45d371
- Observe failure of test cases added to
UNIT_Param_TEST
demonstrating this bug
Output
[ RUN ] Param.Double
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:117: Failure
Expected equality of these values:
sixteenDigits
Which is: 12345678.876543211
value
Which is: 12345700
[ FAILED ] Param.Double (0 ms)
[ RUN ] Param.Vector3d
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:142: Failure
Expected equality of these values:
0.0 + fifteenDigits
Which is: 0.123456789012345
value.X()
Which is: 0.123457
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:143: Failure
Expected equality of these values:
1.0 + fifteenDigits
Which is: 1.123456789012345
value.Y()
Which is: 1.1234599999999999
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:144: Failure
Expected equality of these values:
2.0 + fifteenDigits
Which is: 2.1234567890123448
value.Z()
Which is: 2.1234600000000001
[ FAILED ] Param.Vector3d (0 ms)
[ RUN ] Param.Pose3d
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:176: Failure
Expected equality of these values:
0.0 + fifteenDigits
Which is: 0.123456789012345
value.Pos().X()
Which is: 0.123457
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:177: Failure
Expected equality of these values:
1.0 + fifteenDigits
Which is: 1.123456789012345
value.Pos().Y()
Which is: 1.1234599999999999
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:178: Failure
Expected equality of these values:
2.0 + fifteenDigits
Which is: 2.1234567890123448
value.Pos().Z()
Which is: 2.1234600000000001
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:179: Failure
Expected equality of these values:
0.5 * fifteenDigits
Which is: 0.061728394506172499
value.Rot().Euler().X()
Which is: 0.06172840000000001
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:180: Failure
Expected equality of these values:
1.0 * fifteenDigits
Which is: 0.123456789012345
value.Rot().Euler().Y()
Which is: 0.123457
/Users/scpeters/ws/garden/src/sdformat/src/Param_TEST.cc:181: Failure
Expected equality of these values:
2.0 * fifteenDigits
Which is: 0.24691357802468999
value.Rot().Euler().Z()
Which is: 0.24691400000000005
[ FAILED ] Param.Pose3d (0 ms)