Skip to content

A basic rational (fraction) numbers library for declaring and making calculations

License

Notifications You must be signed in to change notification settings

MertGunduz/rational-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rational.h - C library for fractional numbers

GNU General Public License v3.0


NAME

rational.h


SYNOPSIS

#include "rational.h"


DESCRIPTION

"rational.h" is a C library that provides developers some functions and structs to simplify rational number definitions and declarations by using an automatic denumerator validation function. It contains fractional operation functions for rational expressions.


LIBRARY USAGE

Scientific programming, mathematical analysis, computing, algorithms.


STRUCTURES

1-expression): typedef struct rational {int numerator; int denominator;} rational;

1-description): The main struct for declaring rational expressions.


FUNCTIONS

1-expression): extern void increaseRational(rational *rationalInput);

1-description): Increases the numerator of a rational number by 1.


2-expression): extern void decreaseRational(rational *rationalInput);

2-description): Decreases the numerator of a rational number by 1.


3-expression): extern bool isDenominatorsEqual(rational rationalInput1, rational rationalInput2);

3-description): Checks the denominators and returns true if they are equal, returns false if they are not equal.


4-expression): extern bool isNumeratorsEqual(rational rationalInput1, rational rationalInput2);

4-description): Checks the numerators and returns true if they are equal, returns false if they are not equal.


5-expression): extern bool isRationalsEqual(rational rationalInput1, rational rationalInput2);

5-description): Checks the rational expressions and returns true if they are equal, returns false if they are not equal.


6-expression): extern int getRationalGcd(rational rationalInput);

6-description): Finds the great common divisor of a rational number and returns the gcd value.


7-expression): extern rational multiplyRationals(rational rationalInput1, rational rationalInput2);

7-description): Multiplies two rational numbers and returns the multiplied rational number value.


8-expression): extern rational divideRationals(rational rationalInput1, rational rationalInput2);

8-description): Divides two rational numbers and returns the divided rational number value.


9-expression): extern rational sumRationals(rational rationalInput1, rational rationalInput2);

9-description): Adds two rational numbers and returns the added rational number value.


10-expression): extern rational subtractRationals(rational rationalInput1, rational rationalInput2);

10-description): Subtracts two rational numbers and returns the subtracted rational number value.