From: SourceForge.net <no...@so...> - 2006-10-26 10:20:37
|
Bugs item #1584988, was opened at 2006-10-26 03:20 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1584988&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: pic16 target Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Problem with divulong.c Initial Comment: try: unsigned long longfoo; longfoo = (unsigned long) anyvariable * 13107; longfoo = longfoo/13107; it will return completely errounous results... if you take a closer look at divulong.c sth. seems to be missing there!? How will reste ever be set? #include <sdcc-lib.h> #define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1) unsigned long _divulong (unsigned long a, unsigned long b) _IL_REENTRANT { unsigned long reste = 0L; unsigned char count = 32; unsigned char c; do { // reste: a <- 0; c = MSB_SET(a); a <<= 1; reste <<= 1; if (c) reste |= 1L; if (reste >= b) { reste -= b; // a <- (result = 1) a |= 1L; } } while (--count); return a; } Thanks for any explanation, Nikias Klohr (klohni (at) eti.uni-karlsruhe.de) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1584988&group_id=599 |