[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
 

Re: [CPROG] 2' komplement til decimal



Kim Schulz <sslug@sslug> wrote:

: 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) {

Hmm, er den test fornuftig?

: 		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;
: 			}
: 		}

Her går det galt. Du har vist fra den første øvelse lavet
en opgave i at konvertere fra tal til ascii? Det gøres ved
hhv. at finde remainder med 10 og derefter dividere med 10.

Tager jeg meget fejl hvis der i XLong biblioteket ikke 
findes en XLdiv og en XLrem....

Mvh Morten
-- 



 
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] *