Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #69202

Re: how to c-code it nicely

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: how to c-code it nicely
Date 2015-09-03 21:27 +0100
Organization A noiseless patient Spider
Message-ID <8737yvgsev.fsf@bsb.me.uk> (permalink)
References <88a7de21-3c07-4a40-b603-de2327d22d0b@googlegroups.com> <1fff0591-5284-44ba-a93f-b3dace45e3c5@googlegroups.com>

Show all headers | View raw


"Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:

> On Thursday, September 3, 2015 at 3:47:41 PM UTC-4, fir wrote:
>> this sounds like newbie basic task
>> ("draw star pyramid" or so) but it is
>> indeed a bit harder
>> 
>> void BigIntDivisionTest()
>> {
>>    char* A = "135247"; 
>>    char* B = "235";
<snip>
>> to count C = A/B one needs just to do
>> (if im not wrong) a horissontal loop that 
>> will shift right the B contents and vertical one that will sub B few
>> times form A until
>> can do another shifts
>> 
>> such loop is not damn complex but there
>> task to code it nice is not so damn trivial
>
> Untested, but something like this should work:
>
>     void BigIntDivisionTest()
>     {
>         int     a, b;
>         char*   A       = "135247"; 
>         char*   B       = "235";
>         char    C[32];
>
>         a = atoi(A);
>         b = atoi(B);
>         sprintf(C, "%d", a/b)

I think this is a continuation of the "bignum" discussion -- that's what
the "BigInt" in the name is meant to suggest.  I don't think fir is
interested in strings that are limited to representing (native) int
values.

<snip>
-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-03 12:47 -0700
  Re: how to c-code it nicely "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-09-03 13:00 -0700
    Re: how to c-code it nicely "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-09-03 13:07 -0700
    Re: how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-03 13:19 -0700
    Re: how to c-code it nicely Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-03 21:27 +0100
      Re: how to c-code it nicely "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-09-03 13:33 -0700
        Re: how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-03 14:28 -0700
  Re: how to c-code it nicely Bartc <bc@freeuk.com> - 2015-09-03 21:03 +0100
    Re: how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-04 01:55 -0700
      Re: how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-08 07:59 -0700
      Re: how to c-code it nicely fir <profesor.fir@gmail.com> - 2015-09-08 12:46 -0700
  Re: how to c-code it nicely bartekltg <bartekltg@gmail.com> - 2015-09-03 23:02 +0200
  Re: how to c-code it nicely Melzzzzz <mel@zzzzz.com> - 2015-09-03 23:18 +0200

csiph-web