[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

2' komplement til decimal



hejsa
jeg sidder og prøver at "printe" et unsigned long int array ud som
indeholder følgende: test1.xl[0]   = 0x00000000;  
test1.xl[1] = 0x00000000;
test1.xl[2] = 0x00000001;

eller:
test2.xl[0]   = 0xFFFFFFFF ;
test2.xl[1] = 0xFFFFFF01;
test2.xl[2] = 0xFFFFFFFF;

Det skal skrives ud som decimal tal så [0] = første del af tallet [1] er
anden del og [2] er tredje del. hvordan får jeg det skrevet ud som
decimal? 

jeg prøvede at lave noget kode som ser således ud, men der er vist helt
fu.... up. 

void XLprint(XLong x){
#define XLprintbuflength 1000
	int i = XLprintbuflength - 1;
	int j, rem;
	long int c, newx;
	XLong res;
	char buffer[XLprintbuflength];
	XLpush(x);
	if (x.xl[0] < 0) {
		putchar('-');
		XLneg();
	}
	if (XLiszero()) 
		buffer[i--] = '0';
	else
		for (j=0;j<XLLength;j++){
			c= x.xl[j];
			while (c != 0 && i>=0) {
				newx=c/10;
				rem=c-newx*10;
//				buffer[i--]=i2c(rem);
				putchar(i2c(rem));
				c=newx;
			}
		}




i2c laver en integer om til char 1='1' osv. og XLiszero finder ud af om
den er lige med 0. Resten er vist selvforklarende. 

Det skal bruges til en opgave hvor jeg skal lave et bibliotek der skal
kunne klare 96bit store tal og resten af koden + en makefil kan findes
her: http://www.kampsax.dtu.dk/~schulz/xlong


Nogen der kan hjælpe mig med denne sidste del af opgaven? 

MVH
Kim Schulz






-- 
www.schulz.dk  - En nørds bekendelser  | What happens when you cut
www.guadec.org - tapas, beer and gnome | back the jungle?  It recedes.
                                       | 


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *