offbrand
A collection of generic, reference counted datastructures in C for C
 All Classes Files Functions Variables Typedefs Macros Groups
Typedefs | Functions
obint.h File Reference

obint Public Interface More...

#include "offbrand.h"
#include "obstring.h"

Go to the source code of this file.

Typedefs

typedef struct obint_struct obint
 

Functions

obintobint_new (int64_t num)
 Creates a new obint with the given integer. More...
 
int64_t obint_value (const obint *a)
 Returns the value stored in obint as an integer. More...
 
obintobint_from_string (const obstring *numstr)
 Creates a new obint with value indicated by given string. More...
 
obstringobint_to_string (const obint *a)
 Creates an instance of obstring containing a string representation of the value of an obint. More...
 
obintobint_copy (const obint *a)
 Creates an instance of obint with the same value as the argument obint. More...
 
uint8_t obint_is_zero (const obint *a)
 Checks if an instance of obint is zero and returns the boolean truth value. More...
 
uint8_t obint_is_negative (const obint *a)
 Checks if an instance of obint is negative and returns the boolean truth value. More...
 
obintobint_add (const obint *a, const obint *b)
 Creates a new obint containing the sum of two obint values. More...
 
obintobint_add_primitive (const obint *a, int64_t b)
 Creates a new obint containing the sum of an obint and a machine integer. More...
 
obintobint_subtract (const obint *a, const obint *b)
 Creates a new obint containing the difference of two obint values. More...
 
obintobint_subtract_primitive (const obint *a, int64_t b)
 Creates a new obint containing the difference of an obint and a machine integer. More...
 
obintobint_multiply (const obint *a, const obint *b)
 Creates a new obint containing the product of two obint values. More...
 
obintobint_multiply_primitive (const obint *a, int64_t b)
 Creates a new obint containing the product of an obint and a machine integer. More...
 
obintobint_divide (const obint *a, const obint *b)
 Creates a new obint containing the quotient resule of integer division between two obint values,. More...
 
obintobint_divide_primitive (const obint *a, int64_t b)
 Creates a new obint containing the quotient of an obint and a machine integer. More...
 
obintobint_mod (const obint *a, const obint *b)
 Creates a new obint containing the remainder of integer division between two obint values,. More...
 
obintobint_mod_primitive (const obint *a, int64_t b)
 Creates a new obint containing the remainder of integer division of an obint and a machine integer. More...
 

Detailed Description

obint Public Interface

Author
theck

Typedef Documentation

typedef struct obint_struct obint

Class type declaration

Function Documentation

obint* obint_add ( const obint a,
const obint b 
)

Creates a new obint containing the sum of two obint values.

Parameters
aA non-NULL pointer to type obint
bA non-NULL pointer to type obint
Returns
An instance of obint with value given by a+b
obint* obint_add_primitive ( const obint a,
int64_t  b 
)

Creates a new obint containing the sum of an obint and a machine integer.

Parameters
aA non-NULL pointer to type obint
bA signed 64 bit machine integer
Returns
An instance of obint with value given by a+b
obint* obint_copy ( const obint a)

Creates an instance of obint with the same value as the argument obint.

Parameters
aA non-NULL pointer to type obint
Returns
A copy of the argument obint
obint* obint_divide ( const obint a,
const obint b 
)

Creates a new obint containing the quotient resule of integer division between two obint values,.

Parameters
aA non-NULL pointer to type obint
bA non-NULL pointer to type obint
Returns
An instance of obint with value given by a/b
obint* obint_divide_primitive ( const obint a,
int64_t  b 
)

Creates a new obint containing the quotient of an obint and a machine integer.

Parameters
aA non-NULL pointer to type obint
bA signed 64 bit machine integer
Returns
An instance of obint with value given by a/b
obint* obint_from_string ( const obstring numstr)

Creates a new obint with value indicated by given string.

Parameters
numstrA non-NULL pointer to an obstring instance containing only digit characters and possibly one '-' character at the beginning of the string to indicate a negative value
Returns
An instance of obint with value given by numstr
uint8_t obint_is_negative ( const obint a)

Checks if an instance of obint is negative and returns the boolean truth value.

Parameters
aA non-NULL pointer to type obint
Return values
0The argument is positive
non-zeroThe argument is negative
uint8_t obint_is_zero ( const obint a)

Checks if an instance of obint is zero and returns the boolean truth value.

Parameters
aA non-NULL pointer to type obint
Return values
0The argument is non-zero
non-zeroThe argument is zero
obint* obint_mod ( const obint a,
const obint b 
)

Creates a new obint containing the remainder of integer division between two obint values,.

Parameters
aA non-NULL pointer to type obint
bA non-NULL pointer to type obint
Returns
An instance of obint with value given by ab
obint* obint_mod_primitive ( const obint a,
int64_t  b 
)

Creates a new obint containing the remainder of integer division of an obint and a machine integer.

Parameters
aA non-NULL pointer to type obint
bA signed 64 bit machine integer
Returns
An instance of obint with value given by ab
obint* obint_multiply ( const obint a,
const obint b 
)

Creates a new obint containing the product of two obint values.

Parameters
aA non-NULL pointer to type obint
bA non-NULL pointer to type obint
Returns
An instance of obint with value given by a*b
obint* obint_multiply_primitive ( const obint a,
int64_t  b 
)

Creates a new obint containing the product of an obint and a machine integer.

Parameters
aA non-NULL pointer to type obint
bA signed 64 bit machine integer
Returns
An instance of obint with value given by a*b
obint* obint_new ( int64_t  num)

Creates a new obint with the given integer.

Parameters
numInteger value for new obint
Returns
An instance of obint with value given by num
obint* obint_subtract ( const obint a,
const obint b 
)

Creates a new obint containing the difference of two obint values.

Parameters
aA non-NULL pointer to type obint
bA non-NULL pointer to type obint
Returns
An instance of obint with value given by a-b
obint* obint_subtract_primitive ( const obint a,
int64_t  b 
)

Creates a new obint containing the difference of an obint and a machine integer.

Parameters
aA non-NULL pointer to type obint
bA signed 64 bit machine integer
Returns
An instance of obint with value given by a-b
obstring* obint_to_string ( const obint a)

Creates an instance of obstring containing a string representation of the value of an obint.

Parameters
aA non-NULL pointer to type obint
Returns
An instance of obstring
int64_t obint_value ( const obint a)

Returns the value stored in obint as an integer.

Parameters
aA non-NULL pointer to type obint
Returns
A signed 64 bit integer representing value stored in a
Warning
If the value of the obint cannot be represented in 64 bits then returned value will not represent the true value of the obint