Next: , Previous: , Up: Floating-point Functions   [Index]


7.3 Combined Initialization and Assignment Functions

For convenience, GMP provides a parallel series of initialize-and-set functions which initialize the output and then store the value there. These functions’ names have the form mpf_init_set…

Once the float has been initialized by any of the mpf_init_set… functions, it can be used as the source or destination operand for the ordinary float functions. Don’t use an initialize-and-set function on a variable already initialized!

Function: void mpf_init_set (mpf_t rop, const mpf_t op)
Function: void mpf_init_set_ui (mpf_t rop, unsigned long int op)
Function: void mpf_init_set_si (mpf_t rop, signed long int op)
Function: void mpf_init_set_d (mpf_t rop, double op)

Initialize rop and set its value from op.

The precision of rop will be taken from the active default precision, as set by mpf_set_default_prec.

Function: int mpf_init_set_str (mpf_t rop, const char *str, int base)

Initialize rop and set its value from the string in str. See mpf_set_str above for details on the assignment operation.

Note that rop is initialized even if an error occurs. (I.e., you have to call mpf_clear for it.)

The precision of rop will be taken from the active default precision, as set by mpf_set_default_prec.