[uClinux-dev] BIG numbers more info...

Roope Anttinen roope.anttinen at indagon.com
Thu Mar 6 06:46:39 EST 2003


OK... here's some more code:


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  unsigned long long llInt = 83;
  char str_long[40] = "358505772769";
  printf("16: %llu\n", llInt<<16);
  printf("30: %llu\n", llInt<<30);
  printf("32: %llu\n", llInt<<32);
  llInt = 22022;
  if((83ll << 32) ==0) printf ("ZERO\n");
  else printf("NON ZERO\n");
  llInt += 38ll<<32;
  printf("foo: %llu\n", llInt);
  printf("foo: %llu\n", (llInt/100000));
  llInt = atoll(str_long);
  printf("str: %llu\n", llInt );
  printf("str: %llu\n", (llInt/100000) );
  return 0;
}

on Linux workstation:

ranttine at tossu:~/src/module/module> ./test.exe
16: 5439488
30: 89120571392
32: 356482285568
NON ZERO
foo: 163208779270
foo: 1632087
str: 358505772769
str: 3585057

on uCdimm:

# /mnt/test.gdb
16: 5439488
30: 3221225472
32: 0
NON ZERO
foo: 22022
foo: 1632087
str: 2023487201
str: 3585057

..so it looks like it can handle these long long values, but just can't
print 'em out... OK, I think I can now work my way around this by making
my own string handling function, but it would be nice to be able to use
just the normal library funcions.

And, BTW I use the old uc-libc... can't use uClibc, because it has way
too unreliable signal handling.

/Roope





More information about the uClinux-dev mailing list