converting LARGE decimal number to binary stream

Discussion in 'C++' started by Mariusz Sakowski, Mar 19, 2005.

  1. I'm writing class which will be able to store large numbers (my
    ambition is to make it able to operand on thousands of bits) and
    perform various operations on it (similiar to those available with int
    type). I want to store the number as binary stream, and I don't know
    how to convert large decimal string (char*) to binary stream.
    Converting using MOD would last for hours with really big numbers, and
    in fact I don't know any other ways to convert decimal to binary.

    Maybe someone could advice me how to do it? (i thought of converting
    digit by digit and adding it to final stream using fast operator+
    function, already implemented to work on binary streams, but again how
    could I convert number like k*(10^n), where n could be thousands, to
    binary?)

    I'll appreciate any help, and am sorry for my poor english.
     
    Mariusz Sakowski, Mar 19, 2005
    #1
    1. Advertising

  2. Mariusz Sakowski

    osmium Guest

    "Mariusz Sakowski" writes:

    > I'm writing class which will be able to store large numbers (my
    > ambition is to make it able to operand on thousands of bits) and
    > perform various operations on it (similiar to those available with int
    > type). I want to store the number as binary stream, and I don't know
    > how to convert large decimal string (char*) to binary stream.
    > Converting using MOD would last for hours with really big numbers, and
    > in fact I don't know any other ways to convert decimal to binary.
    >
    > Maybe someone could advice me how to do it? (i thought of converting
    > digit by digit and adding it to final stream using fast operator+
    > function, already implemented to work on binary streams, but again how
    > could I convert number like k*(10^n), where n could be thousands, to
    > binary?)


    How about using BCD arithmetic? In a four-bit nibble store values 0-9.
    Handle the sign as a separate issue. This will be slower and use more RAM,
    but the simplicity gained makes it seem a reasonable tradeoff to me.
     
    osmium, Mar 19, 2005
    #2
    1. Advertising

  3. Mariusz Sakowski

    Edernity Guest

    cze,
    how will you justify using such number without float?
    Isn't that what float is for, very huge number with lots of zero.
    Unless you need a super precision which still useable by bigger float.
    If binary manipulation you are looking for u do need a converter of
    number to bit representation straight into memory/reserve data
    structure. BCD is ok but rather slow for this.
    Edernity
    -----------
    THESE ARE FROM MY PREVIOUS POST. I just wanna say this last time.
    Mercy, Mercy for one without one will be condemn and damn ...ops darn
    by God

    ALRIGHT I'M GIVING ALL THAT ALREADY READ THIS A CHANCE (THIS NG),
    pls help. If my posting is useless I'll go. Remeber that God hate
    miser.
    if it help (IT DON'T CAUSE YOU A CENT. JUST 1 EMAIL THEN FILLING FORMS)
    please do help me provide better school supplies for childrenof
    indonesia.
    IN FACT, for those other who already read this plea and maybe finding
    my post helpful, what is I give you one dollars for it. I don't believe
    this, I'm paying to get people to donate to kids?!!!???that really
    ugly!
    it may be a donation but I merely ask you to letme send email to you
    from one of the product of I'm affiliated and please register there on
    mechant account free. If you even want you refund back on your dollar
    of i-kard, its ok, I'll send you just use regular delivery on shipping
    please. Please note this is very safe since this is a bonafid company.
    remember your credit card company will confirm you on your purchase.
    u can add or remove more credit cards into your account. you can/should
    also ask for always confirmation on send out to you. That will get
    those savage cracker bloke out. even u can use some more free teen
    refillable visa/mastercard from your bank cc account (can be obtaion
    free).
    It is just unnerving seeing how can people do not do anything as so
    they need so little. $10 could support {{{{{the child 1 month.}}}}
    Still have doubts, sign on a personal account and let me contact you
    again on it. just one mail pls
    also
    I'm also affiliated to this site:
    www.getaportal.com/portals/edd y_ruslim
    Unless u wanto e-gold it at 1369872
    New to egold:www.e-gold.com/e-gold.asp?cid= 1369872
    NAH, previous way cost u zilch
    God bless
     
    Edernity, Mar 19, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. makok
    Replies:
    1
    Views:
    6,908
    Anders Hellerup Madsen
    Feb 23, 2004
  2. muss
    Replies:
    13
    Views:
    725
    Vladimir S. Oka
    Mar 27, 2006
  3. ltamisin
    Replies:
    1
    Views:
    139
    Bob Barrows [MVP]
    Jul 14, 2005
  4. Fei Liu
    Replies:
    21
    Views:
    2,414
    John Bokma
    Dec 16, 2006
  5. Replies:
    2
    Views:
    98
    Dave Angel
    May 23, 2013
Loading...

Share This Page