HPGCC3 Documentation 3.0 R003

extreal.h File Reference

Go to the source code of this file.

Data Structures

struct  XREAL
 Extended real type that can contain a calculator real. More...
struct  conversion_data
 Data structure used to convert an XREAL number to string. More...

Defines

#define xr_xr2uint(num)   ((unsigned int)xr_xr2ullong(num))
#define LN2_LN10   1292913987LL
 Constant LN(2)/LN(10) expressed as a 64-bit integer in fixed point, for internal use.

Functions

void xr_10pow (int exp10, XREAL *value)
 Power of 10 as an XREAL number.
char * xr_atoxr (const char *str, XREAL *res)
 Convert a string to an XREAL number.
char * xr_xrtoa (XREAL *number, struct conversion_data *data)
 Convert an XREAL number to string format.
void xr_base2 (XREAL *base10, XREAL *res)
 Change internal representation to a base-2 system.
void xr_base10 (XREAL *base2, XREAL *res)
 Change internal representation to a base-10 system.
void xr_div (XREAL *num, XREAL *div, XREAL *result)
 Basic operator: division.
void xr_mul (XREAL *num1, XREAL *num2, XREAL *result)
 Basic operator: multiplication.
void xr_add (XREAL *num1, XREAL *num2, XREAL *result)
 Basic operator: addition.
void xr_sub (XREAL *num1, XREAL *num2, XREAL *result)
 Basic operator: Subtraction.
void xr_double2xr (double val, XREAL *num)
 Convert a double to an XREAL number.
void xr_int2xr (int val, XREAL *num)
 Convert a 32-bit integer to an XREAL number.
void xr_llong2xr (long long val, XREAL *num)
 Convert a 64-bit integer to an XREAL number.
void xr_uint2xr (unsigned int val, XREAL *num)
 Convert a 32-bit unsigned integer to an XREAL number.
void xr_ullong2xr (unsigned long long val, XREAL *num)
 Convert a 64-bit integer to an XREAL number.
double xr_xr2double (XREAL *num)
 Convert an XREAL number to 'double' format.
long long xr_xr2llong (XREAL *num)
 Convert an XREAL number to 64-bit integer in 'long long' format.
int xr_xr2int (XREAL *num)
 Convert an XREAL number to 32-bit integer.
unsigned long long xr_xr2ullong (XREAL *num)
 Convert an XREAL number to unsigned 64-bit integer in 'unsigned long long' format.
int xr_getbasedigit (char num, int base)
 Internal use.
unsigned long long xr_getbaselimit (int base)
 Internal use.
int xr_getdigits10 (XREAL *xr, char *buffer)
 Internal use.
int xr_getdigits (XREAL *num, char *buffer, int base)
 Internal use.
int xr_getnumbits (int number)
 Internal use.

Define Documentation

#define LN2_LN10   1292913987LL

Constant LN(2)/LN(10) expressed as a 64-bit integer in fixed point, for internal use.

Definition at line 350 of file extreal.h.

#define xr_xr2uint (   num)    ((unsigned int)xr_xr2ullong(num))

Definition at line 53 of file extreal.h.


Function Documentation

void xr_10pow ( int  exp10,
XREAL value 
)

Power of 10 as an XREAL number.

This function returns 10 to the indicated power.

Parameters:
exp10Desired exponent
valuePointer to an XREAL to be filled with the result.
Returns:
The XREAL number (10^exp10) written to the given pointer.
See also:
XREAL
void xr_add ( XREAL num1,
XREAL num2,
XREAL result 
)

Basic operator: addition.

This function calculates num1 + num2 and stores the result.

Parameters:
num1Pointer to an XREAL number
num2Pointer to an XREAL number
resultPointer to an XREAL to be filled with the result. Can be the same as one of the operands.
Returns:
The result of the operation is written at the given result structure.
See also:
XREAL xr_mul xr_sub xr_div
char* xr_atoxr ( const char *  str,
XREAL res 
)

Convert a string to an XREAL number.

This function converts a number stored in text format to the extended real format.

Parameters:
strString with a valid number
resPointer to an XREAL to be filled with the result.
Returns:
A pointer into the given string, pointing to the character after the last valid character considered part of the number. The converted number is written at the given structure.
See also:
xr_xrtoa
void xr_base10 ( XREAL base2,
XREAL res 
)

Change internal representation to a base-10 system.

This function converts a number stored in base-2 format to the base-10 format.

Parameters:
base2Pointer to an XREAL number stored in base-2 format
resPointer to an XREAL to be filled with the result.
Returns:
Number with a right justified mantissa with base-10 exponent (number = mantissa * 10^exponent) The converted number is written at the given structure.
See also:
XREAL xr_base2
void xr_base2 ( XREAL base10,
XREAL res 
)

Change internal representation to a base-2 system.

This function converts a number stored in base-10 format to the base-2 format.

Parameters:
base10Pointer to an XREAL number stored in base-10 format
resPointer to an XREAL to be filled with the result.
Returns:
Number with a left justified mantissa with base-2 exponent (number = mantissa * 2^(exponent-63) The converted number is written at the given structure.
See also:
XREAL xr_base10
void xr_div ( XREAL num,
XREAL div,
XREAL result 
)

Basic operator: division.

This function calculates numerator / denominator and stores the result.

Parameters:
numPointer to an XREAL number (numerator)
divPointer to an XREAL number (denominator)
resultPointer to an XREAL to be filled with the result. Can be the same as one of the operands.
Returns:
The result of the operation is written at the given result structure.
See also:
XREAL xr_add xr_sub xr_mul
void xr_double2xr ( double  val,
XREAL num 
)

Convert a double to an XREAL number.

This function converts a number stored in 'double' format to the extended real format.

Parameters:
valNumber to convert
numPointer to an XREAL to be filled with the result.
Returns:
The converted number is written at the given structure.
See also:
xr_int2xr xr_llong2xr xr_uint2xr xr_ullong2xr
int xr_getbasedigit ( char  num,
int  base 
)

Internal use.

unsigned long long xr_getbaselimit ( int  base)

Internal use.

int xr_getdigits ( XREAL num,
char *  buffer,
int  base 
)

Internal use.

int xr_getdigits10 ( XREAL xr,
char *  buffer 
)

Internal use.

int xr_getnumbits ( int  number)

Internal use.

void xr_int2xr ( int  val,
XREAL num 
)

Convert a 32-bit integer to an XREAL number.

This function converts a number stored in 'int' format to the extended real format.

Parameters:
valNumber to convert
numPointer to an XREAL to be filled with the result.
Returns:
The converted number is written at the given structure.
See also:
xr_double2xr xr_llong2xr xr_uint2xr xr_ullong2xr
void xr_llong2xr ( long long  val,
XREAL num 
)

Convert a 64-bit integer to an XREAL number.

This function converts a number stored in 'int' format to the extended real format.

Parameters:
valNumber to convert
numPointer to an XREAL to be filled with the result.
Returns:
The converted number is written at the given structure.
See also:
xr_double2xr xr_int2xr xr_uint2xr xr_ullong2xr
void xr_mul ( XREAL num1,
XREAL num2,
XREAL result 
)

Basic operator: multiplication.

This function calculates num1 * num2 and stores the result.

Parameters:
num1Pointer to an XREAL number
num2Pointer to an XREAL number
resultPointer to an XREAL to be filled with the result. Can be the same as one of the operands.
Returns:
The result of the operation is written at the given result structure.
See also:
XREAL xr_add xr_sub xr_div
void xr_sub ( XREAL num1,
XREAL num2,
XREAL result 
)

Basic operator: Subtraction.

This function calculates num1 - num2 and stores the result.

Parameters:
num1Pointer to an XREAL number
num2Pointer to an XREAL number
resultPointer to an XREAL to be filled with the result. Can be the same as one of the operands.
Returns:
The result of the operation is written at the given result structure.
See also:
XREAL xr_add xr_mul xr_div
void xr_uint2xr ( unsigned int  val,
XREAL num 
)

Convert a 32-bit unsigned integer to an XREAL number.

This function converts a number stored in 'unsigned int' format to the extended real format.

Parameters:
valNumber to convert
numPointer to an XREAL to be filled with the result.
Returns:
The converted number is written at the given structure.
See also:
xr_double2xr xr_llong2xr xr_int2xr xr_ullong2xr
void xr_ullong2xr ( unsigned long long  val,
XREAL num 
)

Convert a 64-bit integer to an XREAL number.

This function converts a number stored in 'long long' format to the extended real format.

Parameters:
valNumber to convert
numPointer to an XREAL to be filled with the result.
Returns:
The converted number is written at the given structure.
See also:
xr_double2xr xr_llong2xr xr_int2xr xr_uint2xr
double xr_xr2double ( XREAL num)

Convert an XREAL number to 'double' format.

This function converts an XREAL number to the standard C 'double' format.

Parameters:
numNumber to convert
Returns:
The converted number.
See also:
xr_xr2llong xr_xr2int xr_xr2uint xr_xr2ullong
int xr_xr2int ( XREAL num)

Convert an XREAL number to 32-bit integer.

This function converts an XREAL number to the standard C 'int' format.

Parameters:
numNumber to convert
Returns:
The converted number.
See also:
xr_xr2double xr_xr2llong xr_xr2uint xr_xr2ullong
long long xr_xr2llong ( XREAL num)

Convert an XREAL number to 64-bit integer in 'long long' format.

This function converts an XREAL number to the standard C 'long long' format.

Parameters:
numNumber to convert
Returns:
The converted number.
See also:
xr_xr2double xr_xr2int xr_xr2uint xr_xr2ullong
unsigned long long xr_xr2ullong ( XREAL num)

Convert an XREAL number to unsigned 64-bit integer in 'unsigned long long' format.

This function converts an XREAL number to the standard C 'unsigned long long' format.

Parameters:
numNumber to convert
Returns:
The converted number.
See also:
xr_xr2double xr_xr2int xr_xr2uint xr_xr2llong
char* xr_xrtoa ( XREAL number,
struct conversion_data data 
)

Convert an XREAL number to string format.

This function converts a number in XREAL format into a string.

Parameters:
numberThe number to be converted
dataPointer to a structure with all formatting options needed for the conversion.
Returns:
A pointer to a newly allocated string (allocated with malloc, the user is responsible to free the memory block after use). The converted number follows all the formatting specifications given in the 'data' argument.
See also:
xr_atoxr conversion_data