Main Page   Modules   Data Structures   File List   Data Fields   Globals  

translations.cpp File Reference

Implements header. More...

#include "translations.h"
#include "user_interaction_specific.hpp"

Go to the source code of this file.

Data Structures

class  byte_stream

Mathematical operations

Each function performs the indicated operation using each operand and placing the result in the first argument (overwriting the first operand).

The exceptions are the euclide and boolean operations.

It should be noted that infinint operations are in general much slower than fixed size integer operations. This is to be expected of course. However, if the data you are using will not overflow a fixed size variable, use that. It's just faster.

Sample code:


dar_infinint* a = dar_infi(1000);
dar_infinint* b = dar_infds("10345");
dar_infinint* c = dar_infhs("4A3F10");

// a += b
dar_infinint_add( &a, b );

// d = a + b
dar_infinint_add( &a, b );
dar_infinint* d = dar_infinint_copy( a );

// d = a + b  saving a
dar_infinint* t = dar_infinint_copy( a );
dar_infinint_add( &a, b );
dar_infinint* d = dar_infinint_copy( a );
a = dar_infinint_copy( t );
dar_infinint_destroy( t );

// a++
dar_infinint_increment( a );

@endverbatim

void dar_infinint_add (dar_infinint **a, dar_infinint *b)
 Adds two values and replaces the first parameter with the results.

void dar_infinint_sub (dar_infinint **a, dar_infinint *b)
 Subtracts two values and replaces the first parameter with the results.

void dar_infinint_mult (dar_infinint **a, dar_infinint *b)
 Multiplies two values and replaces the first parameter with the results.

void dar_infinint_div (dar_infinint **a, dar_infinint *b)
 Divides two values and replaces the first parameter with the results.

void dar_infinint_pow (dar_infinint **a, dar_infinint *b)
 Takes the first parameter to the second parameter and replaces the first parameter with the results.

void dar_infinint_powi (dar_infinint **a, int exp)
 Takes the first parameter to the second parameter and replaces the first parameter with the results.

void dar_infinint_shiftl (dar_infinint **a, dar_infinint *b)
 Shifts the first parameter to the left b number of times and replaces the first parameter with the results.

void dar_infinint_shiftli (dar_infinint **a, int bit)
 Shifts the first parameter to the left b number of times and replaces the first parameter with the results.

void dar_infinint_shiftr (dar_infinint **a, dar_infinint *b)
 Shifts the first parameter to the right b number of times and replaces the first parameter with the results.

void dar_infinint_shiftri (dar_infinint **a, int bit)
 Shifts the first parameter to the right b number of times and replaces the first parameter with the results.

void dar_infinint_increment (dar_infinint **a)
 Increments the parameter by one.

void dar_infinint_decrement (dar_infinint **a)
 Decrements the parameter by one.

void dar_infinint_euclide (dar_infinint *a, dar_infinint *b, dar_infinint **q, dar_infinint **r)
 Finds the quotient and remainder of the first and second parameters.

bool dar_infinint_comp_eq (dar_infinint *a, dar_infinint *b)
 Determines if the first and second parameters are equal.

bool dar_infinint_comp_leq (dar_infinint *a, dar_infinint *b)
 Determines if the first parameter is less than or equal to the second.

bool dar_infinint_comp_l (dar_infinint *a, dar_infinint *b)
 Determines if the first parameter is less than the second.

bool dar_infinint_comp_geq (dar_infinint *a, dar_infinint *b)
 Determines if the first parameter is greater than or equal to the second.

bool dar_infinint_comp_g (dar_infinint *a, dar_infinint *b)
 Determines if the first parameter is less than the second.

bool dar_infinint_comp_neq (dar_infinint *a, dar_infinint *b)
 Determines if the first and second parameters are not equal.


Functions

void dar_infinint_destroy (dar_infinint *ref)
 Have the libdar library destroy the infinint object.

dar_infinintdar_infinint_copy (dar_infinint *ref)
 Creates a copy of a given infinint.

dar_infinintdar_infpi (int num)
 Create infinint from platform specified integer.

dar_infinintdar_infi (U_32 num)
 Create infinint from library (libdar) specified integer.

dar_infinintdar_infu32 (U_32 num)
 Create infinint from unsigned 32 bit.

dar_infinintdar_infu64 (U_64 num)
 Create infinint from unsigned 64 bit.

dar_infinintdar_infds (char *num)
 Create infinint from decimal string.

dar_infinintdar_infhs (char *num)
 Create infinint from hex string.

dar_infinintdar_infbin (U_8 *num)
 Create infinint from binary infinint data.

int dar_piinf (bool *overflow, dar_infinint *box)
 Extract platform specified integer from infinint.

U_32 dar_iinf (bool *overflow, dar_infinint *box)
 Extract library (libdar) defined integer from infinint.

U_32 dar_u32inf (bool *overflow, dar_infinint *box)
 Extract unsigned 32 bit from infinint.

U_64 dar_u64inf (bool *overflow, dar_infinint *box)
 Extract unsigned 64 bit from infinint.

char * dar_dsinf (U_I *length, dar_infinint *box)
 Extract decimal string from infinint.

char * dar_hsinf (U_I *length, dar_infinint *box)
 Extract hex string from infinint.

U_8 * dar_bininf (U_I *length, dar_infinint *box)
 Extract binary infinint data.


Detailed Description

Implements header.

Definition in file translations.cpp.