As you can see, the values shown in the "time" column are quite ugly. This is due to the rounding issues that many common used "decimal" values (like 0.1, 0.2) cannot be precisely represented in binary-based IEEE 754 floating format. And the native algorithm behind printf just give you the above results.
This is because you used "%.16E" formats to print doubles. I understand that "%lf" is also not a good choice. But there's another way by using some advanced algorithms.
In my patch, with help of David M. Gay's rounding algorithm (taken partially from [1] as third-party sources), the situation gets much better. Now I have the following outputs instead: (It's still not perfect but the situation heavily depends on the specific values, e.g. changing the step to 0.2s results in better shapes of more values).
Hi,
When I run this program with parameters
-s 1.5 -h 0.1
(up to 1.5s, with 0.1s steps), I got outputs like this:As you can see, the values shown in the "time" column are quite ugly. This is due to the rounding issues that many common used "decimal" values (like 0.1, 0.2) cannot be precisely represented in binary-based IEEE 754 floating format. And the native algorithm behind
printf
just give you the above results.This is because you used "%.16E" formats to print doubles. I understand that "%lf" is also not a good choice. But there's another way by using some advanced algorithms.
In my patch, with help of David M. Gay's rounding algorithm (taken partially from [1] as third-party sources), the situation gets much better. Now I have the following outputs instead: (It's still not perfect but the situation heavily depends on the specific values, e.g. changing the step to 0.2s results in better shapes of more values).
[1] https://github.com/jwiegley/gdtoa
I only modified the printing code of "time", for FMI2 only. You may want to use it also on FMI1 related code, or use it to print all double floats.
Regards,
Chun Tian