No description
Find a file
2023-04-24 19:00:40 +02:00
cli Rename several files, structs and functions 2022-11-03 11:32:35 +01:00
include Rename the type digits to digits_t 2023-04-24 19:00:40 +02:00
src Rename the type digits to digits_t 2023-04-24 19:00:40 +02:00
test Rename a function 2022-12-17 18:33:08 +01:00
.gitignore Rework the structure of the project 2022-04-02 19:41:14 +02:00
Makefile Rename several files, structs and functions 2022-11-03 11:32:35 +01:00
README.md Fix the repo url 2022-11-11 11:03:06 +01:00

CMath

A project for my second year of computer science degree. It is composed of a library to manipulate big_ints and an interpreter.

Summary

  1. Detailed description of the project
  2. The project structure
  3. How to compile and run the project
  4. The features of the project

Detailed description

The project is divided into three parts, the library, the tests and the application. The library is composed of functions to manipulate numbers of all sizes and functions for an interpreter.

The application can be launched with two optional options:

  • -i <FILE> To specify the name of the file from which to read the instructions.
  • -o <FILE> To specify the name of the file to which write the results.
  • -e <FILE> To specify the name of the file to which write the errors.

By default, instructions will be read from stdin, the results will be written to stdout and the errors will be written to stderr.

The project structure

.
├─ Makefile
├─ src/                    (The source code of the library)
│  ├─ arithmetic.c
│  ├─ interpreter.c
│  ├─ utils.c
│  └─ big_int.c
├─ include/                (The header files of the library)
│  ├─ arithmetic.h
│  ├─ interpreter.h
│  ├─ utils.h
│  └─ big_int.h
├─ test/                   (The tests of the library)
│  ├─ tests.c
│  ├─ test_big_int.c
│  └─ test_big_int.h
└─ cli/                    (The command line interface)
   └─ main.c

Usage

  1. clone the repository
git clone https://github.com/ocineh/CMath.git
# or
git clone git@github.com:ocineh/CMath.git
  1. build the project or just the library
make library
# or
make build
  1. run the project
./build/app [-i <FILE>] [-o <FILE>] [-e <FILE>] 
  1. run the tests
make test

Features

  • command line interface
    • Parse the arguments of the command line
    • Run the interpreter with the given flags or default values
    • Print the help message
  • library
    • Operations on unbounded numbers
      • Create a big_int from a string
      • Create a big_int from a long long int
      • Transform an big_int to a string
      • Compare two big_int
      • Compare a big_int and a long long int
      • Calculate the sum of two big_int
      • Calculate the difference between two big_int
      • Calculate the product of two big_int
      • Calculate the quotient of two big_int
      • Calculate the modulo of two big_int
      • Calculate the power of two big_int
    • Interpreter
      • (Re)Assign a variable name with a value
      • Evaluate an expression (arithmetic or assignment)
      • Print a variable
      • Free a variable
      • Compare two variables