view doodle/core/misc.d @ 132:bc5baa585b32

Updated to dmd 2.060
author David Bryant <bagnose@gmail.com>
date Thu, 02 Aug 2012 15:32:43 +0930
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?