#ifdef PRINTF_STDLIB
#include <stdio.h>
#endif
#ifdef PRINTF_CUSTOM
#include "tinystdio.h"
#endif

float roundto(float value, unsigned char digits) {
    unsigned long int pw = 10;
    for (unsigned char i = 0; i < digits; i++)
        pw = pw * 10;

    if (value == 0)
        return 0;

    value = value >= 0 ? value + (5.0/pw) : value - (5.0/pw);
    return value;
}
