gmp_lib.mpf_set_prec Method

GMP Native Interface for .NET

gmp_libmpf_set_prec Method
Set the precision of rop to be at least prec bits.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpf_set_prec(
	mpf_t rop,
	mp_bitcnt_t prec
)
Public Shared Sub mpf_set_prec ( 
	rop As mpf_t,
	prec As mp_bitcnt_t
)
public:
static void mpf_set_prec(
	mpf_t^ rop, 
	mp_bitcnt_t prec
)
static member mpf_set_prec : 
        rop : mpf_t * 
        prec : mp_bitcnt_t -> unit 

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
prec
Type: Math.Gmp.Nativemp_bitcnt_t
The minimum precision in bits.
Remarks

The value in rop will be truncated to the new precision.

This function requires a call to realloc, and so should not be used in a tight loop.

Examples
// Create and initialize a new floating-point number x.
mpf_t x = new mpf_t();
gmp_lib.mpf_init(x);

// Set its precision to 64 bits.
gmp_lib.mpf_set_prec(x, 64U);

// Assert that the value of x is 0.0, and that its precision is 64 bits.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);
Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Create and initialize a new floating-point number x.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)

' Set its precision to 64 bits.
gmp_lib.mpf_set_prec(x, 64UI)

' Assert that the value of x is 0.0, and that its precision is 64 bits.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0)
Assert.IsTrue(gmp_lib.mpf_get_prec(x) = 64UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also