libyasm/floatnum.h File Reference

YASM floating point (IEEE) interface. More...

Go to the source code of this file.

Functions

YASM_LIB_DECL void yasm_floatnum_initialize (void)
 Initialize floatnum internal data structures.
YASM_LIB_DECL void yasm_floatnum_cleanup (void)
 Clean up internal floatnum allocations.
YASM_LIB_DECL yasm_floatnumyasm_floatnum_create (const char *str)
 Create a new floatnum from a decimal string.
YASM_LIB_DECL yasm_floatnumyasm_floatnum_copy (const yasm_floatnum *flt)
 Duplicate a floatnum.
YASM_LIB_DECL void yasm_floatnum_destroy (yasm_floatnum *flt)
 Destroy (free allocated memory for) a floatnum.
YASM_LIB_DECL int yasm_floatnum_calc (yasm_floatnum *acc, yasm_expr_op op, yasm_floatnum *operand)
 Floating point calculation function: acc = acc op operand.
YASM_LIB_DECL int yasm_floatnum_get_int (const yasm_floatnum *flt, unsigned long *ret_val)
 Convert a floatnum to single-precision and return as 32-bit value.
YASM_LIB_DECL int yasm_floatnum_get_sized (const yasm_floatnum *flt, unsigned char *ptr, size_t destsize, size_t valsize, size_t shift, int bigendian, int warn)
 Output a yasm_floatnum to buffer in little-endian or big-endian.
YASM_LIB_DECL int yasm_floatnum_check_size (const yasm_floatnum *flt, size_t size)
 Basic check to see if size is valid for flt conversion (using yasm_floatnum_get_sized()).
YASM_LIB_DECL void yasm_floatnum_print (const yasm_floatnum *flt, FILE *f)
 Print various representations of a floatnum.


Detailed Description

YASM floating point (IEEE) interface.

Definition in file floatnum.h.


Function Documentation

YASM_LIB_DECL int yasm_floatnum_calc ( yasm_floatnum acc,
yasm_expr_op  op,
yasm_floatnum operand 
)

Floating point calculation function: acc = acc op operand.

Note:
Not all operations in yasm_expr_op may be supported; unsupported operations will result in an error.
Parameters:
acc floatnum accumulator
op operation
operand floatnum operand
Returns:
Nonzero on error.

YASM_LIB_DECL int yasm_floatnum_check_size ( const yasm_floatnum flt,
size_t  size 
)

Basic check to see if size is valid for flt conversion (using yasm_floatnum_get_sized()).

Doesn't actually check for underflow/overflow but rather checks for size=32,64,80 (at present).

Parameters:
flt floatnum
size number of bits of output space
Returns:
1 if valid size, 0 if invalid size.

YASM_LIB_DECL void yasm_floatnum_cleanup ( void   ) 

Clean up internal floatnum allocations.

YASM_LIB_DECL yasm_floatnum* yasm_floatnum_copy ( const yasm_floatnum flt  ) 

Duplicate a floatnum.

Parameters:
flt floatnum
Returns:
Newly allocated floatnum with the same value as flt.

YASM_LIB_DECL yasm_floatnum* yasm_floatnum_create ( const char *  str  ) 

Create a new floatnum from a decimal string.

The input string must be in standard C representation ([+-]123.456e[-+]789).

Parameters:
str floating point decimal string
Returns:
Newly allocated floatnum.

YASM_LIB_DECL void yasm_floatnum_destroy ( yasm_floatnum flt  ) 

Destroy (free allocated memory for) a floatnum.

Parameters:
flt floatnum

YASM_LIB_DECL int yasm_floatnum_get_int ( const yasm_floatnum flt,
unsigned long *  ret_val 
)

Convert a floatnum to single-precision and return as 32-bit value.

The 32-bit value is a "standard" C value (eg, of unknown endian).

Parameters:
flt floatnum
ret_val pointer to storage for 32-bit output
Returns:
Nonzero if flt can't fit into single precision: -1 if underflow occurred, 1 if overflow occurred.

YASM_LIB_DECL int yasm_floatnum_get_sized ( const yasm_floatnum flt,
unsigned char *  ptr,
size_t  destsize,
size_t  valsize,
size_t  shift,
int  bigendian,
int  warn 
)

Output a yasm_floatnum to buffer in little-endian or big-endian.

Puts the value into the least significant bits of the destination, or may be shifted into more significant bits by the shift parameter. The destination bits are cleared before being set. [0] should be the first byte output to the file.

Note:
Not all sizes are valid. Currently, only 32 (single-precision), 64 (double-precision), and 80 (extended-precision) are valid sizes. Use yasm_floatnum_check_size() to check for supported sizes.
Parameters:
flt floatnum
ptr pointer to storage for size bytes of output
destsize destination size (in bytes)
valsize size (in bits)
shift left shift (in bits)
bigendian endianness (nonzero=big, zero=little)
warn enables standard overflow/underflow warnings
Returns:
Nonzero if flt can't fit into the specified precision: -1 if underflow occurred, 1 if overflow occurred.

YASM_LIB_DECL void yasm_floatnum_initialize ( void   ) 

Initialize floatnum internal data structures.

YASM_LIB_DECL void yasm_floatnum_print ( const yasm_floatnum flt,
FILE *  f 
)

Print various representations of a floatnum.

For debugging purposes only.

Parameters:
f file
flt floatnum


Generated on Thu Jul 24 01:23:31 2008 for libyasm by  doxygen 1.5.2