Thread: Binary Operator Algorithms

  1. #16
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Thanks for the ideas. Sorry for the ignorance, but do you have any thoughts about how one would go about printing the values of such a thing without resorting to repeated mods and divides? That is _extremely_ slow for huge numbers no matter how fast a division algorithm you've.

  2. #17
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Ahh... For printing? Then I think you are stuck converting the values using the method you described (unless of course you are printing in some base 2^n). It because a trade-off at this point: which is more important, printing or some of these operations? The answer of course is dependent on what you want to do with this class.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #18
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    If you want fast bitwise arithmetic, store the number as base 2 or 256 internally, instead of base 10.

    If you're using base 10, the logical result of "n<<1" would be to multiply n by 10.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arrays vs lists? And containers in general!
    By clegs in forum C++ Programming
    Replies: 22
    Last Post: 12-03-2007, 02:02 PM
  2. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM