Esempio n. 1
0
int main()
{
    unsigned oct, dec;
    printf("Enter a decimal number:\n");
    scanf(" %u%*c", &dec);
    tooct(dec);
    tobin(dec);
    printf("Enter an octal number:\n");
    scanf(" %u%*c", &oct);
    oct2bin(oct);
    return 0;
}
Esempio n. 2
0
int main() {

	int dia,mes,ano;
	double data;

	printf("Digite sua data de nascimento no formato DD/MM/AA: ");
	scanf("%d/%d/%d", &dia, &mes, &ano);

	data = dia*100 + mes + ano/100.;
	printf("Data em ponto flutuante: %lf", data);

	tobin(data);
	
	tofloat(data);

	return(0);
}
Esempio n. 3
0
File: scmio.c Progetto: rlk/scmtiff
bool scm_write_data(scm *s, const float *p, uint64_t *oo,
                                            uint64_t *lo,
                                            uint16_t *sc)
{
    // Strip count is total rows / rows-per-strip rounded up.

    int i, c = (s->n + 2 + s->r - 1) / s->r;
    uint64_t o[256];
    uint32_t l[256];

    // Encode each strip for writing. This is our hot spot.

    #pragma omp parallel for
    for (i = 0; i < c; i++)
    {
        tobin(s, s->binv[i], p, i * s->r);
        todif(s, s->binv[i],    i * s->r);
        tozip(s, s->binv[i],    i * s->r, s->zipv[i], l + i);
    }

    *sc = (uint16_t) c;

    return scm_write_zips(s, s->zipv, oo, lo, sc, o, l);
}
Esempio n. 4
0
void
zpcgetuint64(struct zpctoken *token, const char *str, char **retstr)
{
    char     *ptr = (char *)str;
    uint64_t  u64 = 0;

    if (*ptr == '0') {
        ptr++;
        if (*ptr == 'x' || *ptr == 'X') {
            /* hexadecimal value */
            ptr++;
            while (isxdigit(*ptr)) {
                u64 <<= 4;
                u64 += tohex(*ptr);
                ptr++;
            }
            token->radix = 16;
            token->data.ui64.u64 = u64;
        } else if (*ptr == 'b' || *ptr == 'B') {
            /* binary value */
            ptr++;
            while (isxdigit(*ptr)) {
                u64 <<= 1;
                u64 += tobin(*ptr);
                ptr++;
            }
            token->radix = 2;
            token->data.ui64.u64 = u64;
        } else if (isdigit(ptr[1])){
            /* octal value */
            while (isxdigit(*ptr)) {
                u64 <<= 3;
                u64 += tooct(*ptr);
                ptr++;
            }
            token->radix = 8;
            token->data.ui64.u64 = u64;
        }
    } else if (isdigit(*ptr)) {
        /* decimal value */
        while (isdigit(*ptr)) {
            u64 *= 10;
            u64 += todec(*ptr);
            ptr++;
        }
        token->radix = 10;
        token->data.ui64.u64 = u64;
#if 0
    } else if (isxdigit(*ptr)) {
        while (isxdigit(*ptr)) {
            u64 <<= 4;
            u64 += tohex(*ptr);
            ptr++;
        }
        token->data.ui64.u64 = u64;
#endif
    }
    if (*ptr == 'u' || *ptr == 'U' || *ptr == ',') {
        ptr++;
    }
    token->type = ZPCUINT64;
    *retstr = (char *)ptr;

    return;
}