Giter VIP home page Giter VIP logo

biginteger's People

Contributors

rollrat avatar

Stargazers

 avatar

Watchers

 avatar

biginteger's Issues

Error part

bool BigBase::operator<(const this_type& integer) const {
  if (length > integer.length)
    return false;
  else if (length < integer.length)
    return true;
  else if (length == 0 && integer.length == 0)
    return false;
  else {
    for (int ptr = (int)length; --ptr >= 0;)
      if (blocks[ptr] < integer.blocks[ptr]) return true;
      else return false;
    return false;
  }
}

void BigBase::init_decimal(std::string dec) {
  size_t len = dec.length();
  size_t estimate = len * 4;

  allocate(estimate);
  memset(blocks, 0, sizeof(uint32_t) * estimate);

  size_t count = len % 9;
  if (count > 0) {
    blocks[0] = to_int9(dec, 0, count);
  }

  if (len / 9) {
    len -= count;
    for (uint32_t i = 0; i < len; i += 9) {
      uint64_t carry = to_int9(dec, count + i, 9);
      carry += (uint64_t)(blocks[0]) * 1000000000;
      blocks[0] = (uint32_t)carry;
      carry /= 0xFFFFFFFF;
      for (int j = 1; carry; j++) {
        carry += (uint64_t)(blocks[j]) * 1000000000;
        blocks[j] = (uint32_t)carry;
        carry /= 0xFFFFFFFF;
      }
    }
  }

  trim();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.