GithubHelp home page GithubHelp logo

21-decimal's Introduction

21-decimal

PREVIEW_WILL_BE_ADDED_LATER.png

Educational project s21_decimal from organization «School 21» ᅠ Implementation 21_decimal.h library in the C programming language. Library add the ability to work with the "decimal" type, which is not in the language standard. This format can be useful for financial calculations, for example, where calculation error typical of floating-point types are unacceptable.

[ SPOILER ] Overview of implemented code

s21_decimal structure

typedef struct {
    int bits[4];
} s21_decimal;

Arithmetic Operators

No. Function Description Status
1 int s21_add(s21_decimal value_1, s21_decimal value_2, s21_decimal *result) addition
2 int s21_sub(s21_decimal value_1, s21_decimal value_2, s21_decimal *result) subtraction
3 int s21_mul(s21_decimal value_1, s21_decimal value_2, s21_decimal *result) multiplication
4 int s21_div(s21_decimal value_1, s21_decimal value_2, s21_decimal *result) division
5 int s21_mod(s21_decimal value_1, s21_decimal value_2, s21_decimal *result) modulo

Comparison Operators

No. Function Description Status
1 int s21_is_less(s21_decimal, s21_decimal) less than (<) ☑️
2 int s21_is_less_or_equal(s21_decimal, s21_decimal) less than or equal to (<=) ☑️
3 int s21_is_greater(s21_decimal, s21_decimal) greater than (>) ☑️
4 int s21_is_greater_or_equal(s21_decimal, s21_decimal) greater than or equal to (>=) ☑️
5 int s21_is_equal(s21_decimal, s21_decimal) equal to (==) ☑️
6 int s21_is_not_equal(s21_decimal, s21_decimal) not equal to (!=) ☑️

Convertors and parsers

No. Function Description Status
1 int s21_from_int_to_decimal(int src, s21_decimal *dst) from int ☑️
2 int s21_from_float_to_decimal(float src, s21_decimal *dst) from float ☑️
3 int s21_from_decimal_to_int(s21_decimal src, int *dst) to int ☑️
4 int s21_from_decimal_to_float(s21_decimal src, float *dst) to float ☑️

Another functions

No. Function Description Status
1 int s21_floor(s21_decimal value, s21_decimal *result) rounds a specified Decimal number to the closest integer toward negative infinity
2 int s21_round(s21_decimal value, s21_decimal *result) rounds a decimal value to the nearest integer
3 int s21_truncate(s21_decimal value, s21_decimal *result) returns the integral digits of the specified Decimal; any fractional digits are discarded, including trailing zeroes
4 int s21_negate(s21_decimal value, s21_decimal *result) returns the result of multiplying the specified Decimal value by negative one

— Developer: RV-304 (@rynortheast) ✅, Artem Kain (@artemxgod) ☑️
— Thanks to 21-SCHOOL for provided assignment and special learning conditions ✌️🔥

Usage

  1. Clone this repository via
    • SSH [email protected]:rynortheast/21-decimal.git or
    • HTTPS https://github.com/rynortheast/21-decimal.git
  2. Change code base if necessary
  3. Run make test to build project and run main tests
  4. Run make personal to build project and run personal code
  5. Run make s21_decimal.a to build a static lib

21-decimal's People

Contributors

rynortheast avatar

Watchers

 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.