opCmp / opEquals do not actually support partial orders
Ivan Kazmenko
gassa at mail.ru
Wed Jul 18 15:03:58 UTC 2018
On Wednesday, 18 July 2018 at 14:02:28 UTC, Dominikus Dittes
Scherkl wrote:
> On Wednesday, 18 July 2018 at 13:12:05 UTC, Ivan Kazmenko wrote:
>> Leaving x uninitialized, or using floats, work about the same.
> No, floats are a whole lot less slow.
Are they? Locally, I don't see much difference. Code:
-----
import std.datetime.stopwatch, std.math, std.stdio;
immutable float limit = 10 ^^ 7;
void main () {
int s;
auto sw = StopWatch (AutoStart.yes);
auto start = sw.peek ();
for (float x = NaN (0), i = 0; i < limit; i++)
s += (i < x);
auto now = sw.peek ();
writeln (now - start, ", sum is ", s);
}
-----
Result:
-----
1 sec, 467 ms, 40 μs, and 6 hnsecs, sum is 0
-----
Fluctuating within a few per cent, but very similar to version
with doubles.
That's by DMD32 on Windows. (Sorry, my DMD64 broke after
upgrading Visual Studio to 2017, and I failed to fix it right
now. Anyway, it's not like x86_64 uses a different set of
general purpose floating-point hardware, right?)
Ivan Kazmenko.
More information about the Digitalmars-d
mailing list