post
poster: G-man
description: Datatypes limits/bits thing
language: C
[download]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <math.h>
#include <limits.h>

double maxnumber(int);

int main(int argc, char *argv[]){
    printf("You say: %.lf\nlimits.h says: %d.\n", maxnumber(8*sizeof(int)),
    INT_MAX);
    system("PAUSE");
    return 0;
}

double maxnumber(int bits){
    int counter = 0;
    double number;
    while(counter != bits){
        number += pow(2,counter);
        counter = counter + 1;    
    }
    number = number / 2 - 1;
    return number;
}