view doodle/core/misc.d @ 101:523269b36711

Update to dmd 2.050
author David Bryant <bagnose@gmail.com>
date Thu, 28 Oct 2010 16:35:11 +1030
parents 15ca7d5cd1ed
children
line wrap: on
line source

module doodle.core.misc;

// Basic routines.
// Note, most of these are probably provided by phobos.

double min(in double a, in double b) {
    return a < b ? a : b;
}

double max(in double a, in double b) {
    return a > b ? a : b;
}

double clamp(in double v, in double min, in double max) {
    assert(min < max);

    if (v < min) { return min; }
    else if (v > max) { return max; }
    else { return v; }
}

// wrap?