Apollo Hogan:

import std.stdio;

struct Pair { double hi, lo; }

Pair normalize(Pair q) {
    immutable h = q.hi + q.lo;
    immutable l = q.lo + (q.hi - h);
    return Pair(h, l);
}
void main() {
    immutable static Pair spn = Pair(1.0, 0.1).normalize;
    spn.writeln;
    Pair(1.0, 0.1).writeln;
    Pair(1.0, 0.1).normalize.writeln;
}

...>ldmd2 -O -run temp.d
immutable(Pair)(1.1, -2.03288e-020)
Pair(1, 0.1)
Pair(1.1, -8.32667e-017)

...>ldmd2 -run temp.d
immutable(Pair)(1.1, -2.03288e-020)
Pair(1, 0.1)
Pair(1.1, -8.32667e-017)

ldc2 0.11.0

Bye,
bearophile

Reply via email to