Thread: about the digit size in libtommath

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    36

    about the digit size in libtommath

    In the libtommath library documentation file, what does it mean by the
    "default value of mp_digit being ISO C unsigned long data type, each
    digit is 28 bits long" ? Shouldn't it be 32 bits? It shows 4 bytes
    when I use sizeof and looking at the source code it seems to be
    defined as
    typedef unsigned long mp_digit

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    My guess is that it simplifies the internal code, when it comes to detecting things like overflow.

    You would have to read the code, read the design documents, or ask on the forum dedicated to libtommath maintainers and developers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I once thought that it would make overflow detection easier, but then I found out that it's easy anyway.
    I use all 32-bits in my own one.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Take answer, and post elsewhere -> About the digit size in libtommath - Dev Shed
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do I use/install libtommath?
    By mahaju in forum C Programming
    Replies: 20
    Last Post: 12-28-2011, 08:07 AM
  2. Adding a number digit by digit.
    By sdfx in forum C Programming
    Replies: 4
    Last Post: 05-10-2011, 05:54 PM
  3. Read from file - 1-digit and 2-digit numbers
    By Bonaventura in forum C Programming
    Replies: 8
    Last Post: 03-06-2010, 06:33 AM
  4. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 23
    Last Post: 09-21-2007, 03:00 PM
  5. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 1
    Last Post: 09-14-2007, 03:28 AM