Exemplo n.º 1
0
LVAL xlc_log(void)
{
    double arg1 = getflonum(xlgaflonum());
    double result;

    xllastarg();
    result = xlog(arg1);
    return cvflonum(result);
}
Exemplo n.º 2
0
LVAL xlc_snd_set_latency(void)
{
    double arg1 = getflonum(xlgaflonum());
    double result;

    xllastarg();
    result = snd_set_latency(arg1);
    return cvflonum(result);
}
Exemplo n.º 3
0
/* xwrfloat - write a float to a file */
LVAL xwrfloat(void)
{
    LVAL val, fptr;
    union {
        char b[8];
        float f;
        double d;
    } v;
    int n = 4;
    int i;
    int index = 3;  /* where to start in array */
    int incr = -1;  /* how to step through array */

    /* get the float and file pointer and optional byte count */
    val = xlgaflonum();
    fptr = (moreargs() ? xlgetfile() : getvalue(s_stdout));
    if (moreargs()) {
        LVAL count = typearg(fixp);
        n = getfixnum(count);
        if (n < 0) {
            n = -n;
            index = 0;
            incr = 1;
        }
        if (n != 4 && n != 8) {
            xlerror("must be 4 or 8 bytes", count);
        }
    }
    xllastarg();

#ifdef XL_BIG_ENDIAN
    /* flip the bytes */
    index = n - 1 - index;
    incr = -incr;
#endif
    /* build output v.b */
    if (n == 4) v.f = (float) getflonum(val);
    else v.d = getflonum(val);

    /* put bytes to the file */
    for (i = 0; i < n; i++) {
        xlputc(fptr, v.b[index]);
        index += incr;
    }

    /* return the flonum */
    return val;
}