Code Monkey home page Code Monkey logo

basemax / bignumberc Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 64 KB

The Big Number C library is a C library for arbitrary precision arithmetic. It can be used to perform arithmetic operations on numbers of arbitrary size. It is written in C and is designed to be portable and efficient. You can work with numbers of any size, and the library will automatically allocate memory as needed.

License: GNU General Public License v3.0

C 100.00%
big-number big-number-calculation big-number-multiplication big-numbers bignumber bignumbers c c-library number-converter

bignumberc's Introduction

Big Number C (BigNumberC)

The Big Number C library is a C library for arbitrary precision arithmetic. It can be used to perform arithmetic operations on numbers of arbitrary size. It is written in C and is designed to be portable and efficient. You can work with numbers of any size, and the library will automatically allocate memory as needed.

BigNumber Functions

  • BigNumber* createBigNumber(int size): Create a Big Number object
  • void setBigNumber(BigNumber *bn, int *digits, int size): Set the Big Number object
  • BigNumber* createAndSetBigNumber(int *digits, int size): Create a Big Number object and set it digits
  • void destroyBigNumber(BigNumber *bn): Destroy the Big Number object
  • void printBigNumber(BigNumber *bn): Print the Big Number object
  • BigNumber* addBigNumbers(BigNumber *bn1, BigNumber *bn2): Add two Big Numbers
  • BigNumber* multiplyBigNumbers(BigNumber *bn1, BigNumber *bn2): Multiply two Big Numbers
  • BigNumber* copyBigNumber(BigNumber *bn): Deep copy a Big Number
  • BigNumber* minusBigNumbers(BigNumber *bn1, BigNumber *bn2): Minus two Big Numbers
  • BigNumber* divideBigNumbers(BigNumber *bn1, BigNumber *bn2): Divide two Big Numbers
  • BigNumber* remainderBigNumbers(BigNumber *bn1, BigNumber *bn2): Remainder two Big Numbers
  • int compareBigNumbers(BigNumber *bn1, BigNumber *bn2): Compare two Big Numbers

BigNumber Header

#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int *digits;
    int size;
} BigNumber;

/**
 Create a Big Number object
 * 
 * @param size 
 * @return BigNumber* 
 */
BigNumber* createBigNumber(int size)

/**
 Set the Big Number object
 * 
 * @param bn
 * @param digits
 * @param size
 */
void setBigNumber(BigNumber *bn, int *digits, int size)

/**
 Create a Big Number object and set it digits
 * 
 * @param digits
 * @param size
 * @return BigNumber* 
 */
BigNumber* createAndSetBigNumber(int *digits, int size)

/**
 Destroy the Big Number object
 * 
 * @param bn 
 */
void destroyBigNumber(BigNumber *bn)

/**
 Print the Big Number object
 * 
 * @param bn 
 */
void printBigNumber(BigNumber *bn)

/**
 Add two Big Numbers
 * 
 * @param bn1 
 * @param bn2 
 * @return BigNumber* 
 */
BigNumber* addBigNumbers(BigNumber *bn1, BigNumber *bn2)

/**
 Multiply two Big Numbers
 * 
 * @param bn1 
 * @param bn2 
 * @return BigNumber* 
 */
BigNumber* multiplyBigNumbers(BigNumber *bn1, BigNumber *bn2)

/**
 Deep copy a Big Number
 * 
 * @param bn
 * @return BigNumber* 
 */
BigNumber* copyBigNumber(BigNumber *bn)

/**
 Minus two Big Numbers
 * 
 * @param bn1
 * @param bn2
 * @return BigNumber*
 */
BigNumber* minusBigNumbers(BigNumber *bn1, BigNumber *bn2)

/**
 Divide two Big Numbers
 * 
 * @param bn1
 * @param bn2
 * @return BigNumber*
 */
BigNumber* divideBigNumbers(BigNumber *bn1, BigNumber *bn2)

/**
 Remainder two Big Numbers
 * 
 * @param bn1
 * @param bn2
 * @return BigNumber*
 */
BigNumber* remainderBigNumbers(BigNumber *bn1, BigNumber *bn2)

/**
 Compare two Big Numbers
 * 
 * @param bn1
 * @param bn2
 * @return int
 */
int compareBigNumbers(BigNumber *bn1, BigNumber *bn2)

TODO

  • Memory optimization
  • Add more functions
  • Add more tests
  • Add more documentation

© Copyright 2022, Max Base

bignumberc's People

Contributors

basemax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.