[cs631apue] Size of large ints
yluo4
yluo4 at stevens.edu
Sun Oct 13 19:33:18 EDT 2013
I think you can use following code:
len = 1;
while (size / 10) {
len++;
}
to get the len of the size.
On 10/13/2013 5:06 PM, Paul-Anthony Dudzinski wrote:
> Hey all,
> I am looking for a good way to measure the size of a large integer for
> instance when I run my program on /tmp I get:
>
> pdudzins at gits:~/cs631/midterm$ ./a.out -l /tmp
>
> drwxrwxrwx 2 root root 4096 .X11-unix
> -rw------- 1 jschauma professor 10724 1
> drwxr-xr-x 3 swatts student 4096 VisualGDB-RW------- 1
> JSCHAUMA PROFESSOR 2097152000 BIG
> -rwxr-xr-x 1 swatts student 56 dump-gdb-settings
> -rw-r--r-- 1 jschauma professor 2041 f
> -rw------- 1 jschauma professor 2041 file
> drwxr-xr-x 2 jsexton student 4096 hsperfdata_jsexton
> drwxr-xr-x 2 lxiong student 4096 hsperfdata_lxiong
> drwxr-xr-x 2 snatara1 student 4096 hsperfdata_snatara1
> -rw------- 1 fcannava professor 611 krb5cc_11084_S26665
> -rw------- 1 jrisi student 605 krb5cc_11492_u17070
> -rw------- 1 pdudzins student 611 krb5cc_11909_Iq7884
> drwx------ 2 jschauma professor 4096 ssh-OkXFz27774
>
> And the bolded line is messing up my column print lengh. When I
> measure the size of the size I am doing it like this:
>
> nlen_size = sizeof(a->fts_statp->st_size);
> if (nlen_size > len_size)
> len_size = nlen_size;
>
> And I keep getting 8 instead of 10 which I am pretty sure the 8 bytes
> it takes to store an int...
>
> Has anyone tried casting this as a character array and taking the size
> that way? Is there a library function that will just do this?
>
>
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
More information about the cs631apue
mailing list