amrali #: @fxsaber NormalizeDouble rounds to decimal places, which is different from rounding to significant digits. SF is 1-15 or 17 inclusive. There is no 0.
Significant figures (also known as the significant digits , precision or resolution ) of a number in positional notation are digits in the number that are reliable and necessary to indicate the quantity of something. If a number expressing the result of a measurement (e.g., length, pressure, volume, or mass) has more digits than the number of...
But, when I came back today, I found you benchmarked it wrongly. You just benchmarked the modulo % operator, but with some compiler's internal optimizations you got that unrealistic difference.
I used this simple benchmark to re-check. Both functions are fast enough. So, no change!
But, when I came back today, I found you benchmarked it wrongly. You just benchmarked the modulo % operator, but with some compiler's internal optimizations you got that unrealistic difference.
I used this simple benchmark to re-check. Both functions are fast enough. So, no change!
You are drawing wrong conclusions.
Benchmark(runs, sum1 += EqualDoubles(1.2345, 5.4321, i ? 10 : 15));
Benchmark(runs, sum1 += EqualDoubles_v2(1.2345, 5.4321, i ? 10 : 15));
means the function calls were not optimized by the compiler. I do not know why you manipulate the 3rd argument, leave it as a default parameter and re-test.
Use a simple loop.
voidOnStart()
{
double sum = 0; // use double to avoid optimizing expression out.uint t1 = GetTickCount();
for (int i = 0; i < runs; ++i)
{
sum += !EqualDoubles(1.12345, 5.12345);
}
Print("EqualDoubles -> ", GetTickCount() - t1, " msec"); // 109 msecPrint(sum);
uint t2 = GetTickCount();
for (int i = 0; i < runs; ++i)
{
sum += !EqualDoubles_v2(1.12345, 5.12345);
}
Print("EqualDoubles -> ", GetTickCount() - t2, " msec"); // 125 msecPrint(sum);
}
means the function calls were not optimized by the compiler. I do not know why you manipulate the 3rd argument, leave it as a default parameter and re-test.
Use a simple loop.
Unfortunately, you do not understand what you are measuring.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
@fxsaber NormalizeDouble rounds to decimal places, which is different from rounding to significant digits. SF is 1-15 or 17 inclusive. There is no 0.
Didn't understand.
NormalizeDouble(12.345, 2) -> 12.35
RoundToSignificantDigits(12.345, 2) -> 12
EqualDouble() is used to compare suspected equal amounts like 1.123456 and 1.23456789
also can be used very large numbers like 1234567891234.1234 and 1234567891234.1255
without knowing the decimal digits in the numbers you comapre against each other.https://www.wikiwand.com/en/Significant_figures
https://chem.libretexts.org/Bookshelves/General_Chemistry/Book%3A_Chem1_(Lower)/04%3A_The_Basics_of_Chemistry/4.06%3A_Significant_Figures_and_Rounding
https://www.calculatorsoup.com/calculators/math/significant-figures-rounding.php
Forum on trading, automated trading systems and testing trading strategies
Libraries: Math Utils
fxsaber, 2023.02.21 21:01
You need to learn how to make proper performance measurements.
21 times faster.
@fxsaber I did not check after you, yesterday!
But, when I came back today, I found you benchmarked it wrongly. You just benchmarked the modulo % operator, but with some compiler's internal optimizations you got that unrealistic difference.
I used this simple benchmark to re-check. Both functions are fast enough. So, no change!
@fxsaber I did not check after you, yesterday!
But, when I came back today, I found you benchmarked it wrongly. You just benchmarked the modulo % operator, but with some compiler's internal optimizations you got that unrealistic difference.
I used this simple benchmark to re-check. Both functions are fast enough. So, no change!
You are drawing wrong conclusions.
// 200000000.0means the function calls were not optimized by the compiler. I do not know why you manipulate the 3rd argument, leave it as a default parameter and re-test.
Use a simple loop.
means the function calls were not optimized by the compiler. I do not know why you manipulate the 3rd argument, leave it as a default parameter and re-test.
Use a simple loop.
Unfortunately, you do not understand what you are measuring.
Disable compiler optimizations and give it a try.
So, why to disable? I write the function, then I depend on the optimizing compiler.
Otherwise, I would program in assembly like in the old days :-)