Re: String of digits, certain radix, perform division

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick Keighley

    Re: String of digits, certain radix, perform division

    On Oct 25, 1:50 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
    Tomás Ó hÉilidhe wrote:
    I have a radix, and I have a string of digits representing a number:
    >
    unsigned digits[] = {1,5,12,7,9,10, 4,8};
    >
    The radix is 13. The most significant digit is on the left. So the
    actual value of this number is calculable as:
    >
    1*(13^0) + 5*(13^1) + 12*(13^2) + 7*(13^3) + 9*(13^4) + 10*(13^5) +
    4*(13^6) + 8(13^7)
    >
         Where, again, is the most significant digit?  You said
    "left," but the formula indicates "right."
    >
    I'm stuck with this format, I can't change it. As parameters to my
    function, I get the radix, the digit array, and a pointer to the last
    digit. So altogether its:
    >
    struct Number {
        unsigned radix;
        unsigned *p_flast_digit;
        unsigned digits[N];
    };
    >
         You also need the number of digits, or equivalent information.
    Is that `N'?  If so, what's the use of the pointer?
    since the pointer indicates the "last" digit. It indicates how
    many digits there are. I'm guessing that N is just some large number

    <snip>

    --
    Nick Keighley
Working...