Welcome to the GMP Native Interface for .NET Library

GMP Native Interface for .NET
Welcome to the GMP Native Interface for .NET Library

The GMP Native Interface for .NET Library exposes to .NET (through P-Invoke and .NET types) all of the functionality of the GNU MP Library (version 6.1.2). It automatically loads at runtime the 32-bit or 64-bit GNU MP library that matches the current CPU architecture, thus allowing building Visual Studio Projects for Any CPU, x86, or x64. It is based on the GNU MP "fat" build which automatically detects the current CPU type, and selects any available assembly language code optimization for that CPU, thus providing best performance.

Source Code

The source code of the library is available on GitHub in the project Math.Gmp.Native.

NuGet Package

You can use the library by loading it from the NuGet package Math.Gmp.Native.NET.

Overview

The gmp_lib class has a static method for each one of the GNU MP functions. Other types are defined to mimic struct's and typedef's of the GNU MP and C libraries, as well as C language constructs such as char * and void *.

The GMP Native Interface for .NET Library relies on pre-built 32-bit and 64-bit versions of the GNU MP Library. Instructions for building the GNU MP Library on Windows are given below.

For convenience, this help file has been created from the GNU MP manual version 6.1.2. It shows with examples how each GNU MP function is called in .NET. For an introduction to GNU MP, refer to the GNU MP Manual.

C and .NET Types Equivalence

The table below shows how each C type maps to .NET. Note that the mp_limb_t and size_t C types map to the CPU word, i.e., 32 or 64 bits. In particular, because mp_limb_t is the type of the integers that make up multi-precision numbers, matching the CPU word size ensures maximum performance. Unless you intend to use low-level (mpn) functions, you do not need to take into account the CPU word size, and can build for the "Any CPU" platform.

C Types | .NET Types
short | Int16 / short (C#) / Short (VB.NET)
int | Int32 / int (C#) / Integer (VB.NET)
long | Int32 / int (C#) / Integer (VB.NET)
long long | Int64 / long (C#) / Long (VB.NET)
mp_bitcnt_t | UInt32 / uint (C#) / UInteger (VB.NET)
mp_exp_t | Int32 / int (C#) / Integer (VB.NET)
mp_size_t | Int32 / int (C#) / Integer (VB.NET)
mp_limb_t | UInt32 (on 32-bit CPU) / UInt64 (on 64-bit CPU)
size_t | UInt32 (on 32-bit CPU) / UInt64 (on 64-bit CPU)
Building the GNU MP Library on Windows

  1. Install MSYS2.

    On a 64-bit computer, install msys2-x86_64-20161025.exe, and on a 32-bit computer, install msys2-i686-20161025.exe. You can also check for a more recent version of MSYS2 here. Install MSYS2 to its default location.

    After installation, you need to updates MSYS2 packages. From the Windows Start Menu, start MSYS2 MSYS. In the shell command window, enter the command:

    • pacman -Syuu

    and follow instructions. You will have to close the command window, reopen a new one, and reenter the command pacman -Syuu.

    Finally, in order to build software, you need to install a number of packages with the command:

    • pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake

    run from the same command window as in the previous step.

    To build 32-bit software, use the MSYS2 MinGW 32-bit command from the Windows Start Menu, and for 64-bit software, use MSYS2 MinGW 64-bit.

  2. Install yasm.

    On a 64-bit computer, copy yasm-1.3.0-win64.exe to C:\msys64\usr\bin, and rename it to yasm.exe.

    Similarly on a 32-bit computer, copy yasm-1.3.0-win32.exe to C:\msys32\usr\bin, and rename it to yasm.exe.

  3. Build GNU MP.

    Create folders C:\Temp\x86 and C:\Temp\x64. These are the folder where the compiled 32-bit and 64-bit versions of GNU MP will be installed. Unzip gmp-6.1.2.tar.bz2 in folder C:\Temp. This puts GNU MP in subfolder gmp-6.1.2.

    In each one of the command windows openend with the commands MSYS2 MinGW 32-bit and MSYS2 MinGW 64-bit from the Windows Start Menu, run the commands below:

    • cd /c/Temp/gmp-6.1.2
      ./configure --enable-fat --disable-static --enable-shared --prefix=/c/Temp/x86 or x64
      make
      make check
      make install

    The --prefix specifies the install folder. Note that the Windows C:\ drive is specified as the root /C/ folder in the MinGW window. Note also that the configure and make commands are to be run against a fresly uncompressed GNU MP source. The make install command creates libgmp-10.dll in the C:\Temp\x86 and C:\Temp\x64 folders. These two compiled versions of the GNU MP library are to be copied to the x86 and x64 folders of the Math.Gmp.Native Visual Studio projects. They can also be copied directly into the x86 and x64 folders of the bin/Debug or bin/Release folders.

    The 32-bit and 64-bit make check commands generate some warnings, but all tests passed successfully.

Building the GNU MP Library for a Specific CPU Type on Windows

The --enable-fat build option above creates a library where optimized low level subroutines are chosen at runtime according to the CPU detected. By using instead the --host option, you can build a library for a specific CPU type. You will end up with a library that runs only on that CPU type, but the library will be samller. See the Build Options from the GNU MPFR Manual for the supported CPU types.

Using the GNU MP Library in a Visual Studio C++ Project

Although our main goal was to compile GNU MP in order to use it from .NET, the compiled 32-bit and 64-bit GNU MP libraries may be used directly in Visual Studio C++ projects. For example, create a default Visual Studio C++ Console Application. Set the Platform to x64. Copy from the C:\Temp\x64 folder the files include\gmp.h, bin\libgmp-10.dll, and lib\libgmp.dll.a to the Visual Studio C++ project folder. Include gmp.h in your C++ source file. In the Linker, Input Property Page of the project, add libgmp.dll.a to the Additional Dependencies. Build your C++ project, and copy libgmp-10.dll to the output bin folder. Run your application.

See ConsoleApplication12.zip for a sample Visual Studio C++ project.

See Also

Other Resources

MSYS2
yasm
GNU MP
Math.Gmp.Native on GitHub


Math.Gmp.Native Namespace

Math.Gmp.Native Namespace
The Math.Gmp.Native namespace contains types defined to expose all of the GNU GMP functionality to .NET.
Classes
 | Class | Description
Public class | gmp_lib | Represents all of the functions of the GNU MP library.
Public class | gmp_randstate_t | Represents the state of a random number generator.
Public class | mp_base | Provides common functionality to mpz_t, mpf_t, and gmp_randstate_t.
Public class | mp_ptr | Represents a pointer to an array of mp_limb_t values in unmanaged memory,
Public class | mpf_t | Represents a multiple precision floating-point number.
Public class | mpq_t | Represents a multiple precision rational number.
Public class | mpz_t | Represents a multiple precision integer.
Public class | ptrT | Represents a pointer to a value of type T.
Public class | va_list | Represent a variable argument list.
Structures
 | Structure | Description
Public structure | char_ptr | Represents a pointer to a string in unmanaged memory.
Public structure | FILE | Represents a file stream.
Public structure | mp_bitcnt_t | Represents a count of bits.
Public structure | mp_exp_t | Represents the exponent of a floating-point number.
Public structure | mp_limb_t | Represents a part of a multiple precision number.
Public structure | mp_size_t | Represents a count of limbs.
Public structure | size_t | Represents a count of characters or bytes.
Public structure | void_ptr | Represents a pointer to a block of unmanaged memory.
Delegates
 | Delegate | Description
Public delegate | allocate_function | Return a pointer to newly allocated space with at least alloc_size bytes.
Public delegate | free_function | De-allocate the space pointed to by ptr.
Public delegate | reallocate_function | Resize a previously allocated block ptr of old_size bytes to be new_size bytes.


allocate_function Delegate

allocate_function Delegate
Return a pointer to newly allocated space with at least alloc_size bytes.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public delegate void_ptr allocate_function(
    size_t alloc_size
)
Public Delegate Function allocate_function (
    alloc_size As size_t
) As void_ptr
public delegate void_ptr allocate_function(
    size_t alloc_size
)
type allocate_function =
    delegate of
        alloc_size : size_t -> void_ptr

Parameters

alloc_size
Type: Math.Gmp.Nativesize_t
The minimum number of bytes to allocate.

Return Value

Type: void_ptr
A pointer to newly allocated space with at least alloc_size bytes.
See Also

Reference

Math.Gmp.Native Namespace


char_ptr Structure

char_ptr Structure
Represents a pointer to a string in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct char_ptr
Public Structure char_ptr
public value class char_ptr
[<SealedAttribute>]
type char_ptr =  struct end

The char_ptr type exposes the following members.

Constructors
 | Name | Description
Public method | char_ptr(IntPtr) | Creates new string using an already allocated string in unmanaged memory.
Public method | char_ptr(String) | Creates new string in unmanaged memory and initializes it with str.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(char_ptr) | Returns a value indicating whether this instance is equal to a specified char_ptr value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToIntPtr | Gets pointer to string in unmanaged memory.
Public method | ToString | Gets the .NET string equivalent of the unmanaged string. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Pointer | Pointer to string in unmanaged memory.
 | Zero | Gets a null char_ptr.
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace


char_ptr Constructor

char_ptr Constructor
Overload List
 | Name | Description
Public method | char_ptr(IntPtr) | Creates new string using an already allocated string in unmanaged memory.
Public method | char_ptr(String) | Creates new string in unmanaged memory and initializes it with str.
Top
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr Constructor (IntPtr)

char_ptr Constructor (IntPtr)
Creates new string using an already allocated string in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public char_ptr(
    IntPtr pointer
)
Public Sub New (
    pointer As IntPtr
)
public:
char_ptr(
    IntPtr pointer
)
new :
        pointer : IntPtr -> char_ptr

Parameters

pointer
Type: SystemIntPtr
Pointer to existing string in unmanaged memory.
See Also

Reference

char_ptr Structure
char_ptr Overload
Math.Gmp.Native Namespace


char_ptr Constructor (String)

char_ptr Constructor (String)
Creates new string in unmanaged memory and initializes it with str.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public char_ptr(
    string str
)
Public Sub New (
    str As String
)
public:
char_ptr(
    String^ str
)
new :
        str : string -> char_ptr

Parameters

str
Type: SystemString
The value of the new string.
Remarks

When done with the string, unmanaged memory must be released with free.

See Also

Reference

char_ptr Structure
char_ptr Overload
Math.Gmp.Native Namespace


char_ptr Methods

char_ptr Methods

The char_ptr type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(char_ptr) | Returns a value indicating whether this instance is equal to a specified char_ptr value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToIntPtr | Gets pointer to string in unmanaged memory.
Public method | ToString | Gets the .NET string equivalent of the unmanaged string. (Overrides ValueTypeToString.)
Top
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Equals Method

char_ptrEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(char_ptr) | Returns a value indicating whether this instance is equal to a specified char_ptr value.
Top
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Equals Method (Object)

char_ptrEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of char_ptr and equals the value of this instance; otherwise, False.
See Also

Reference

char_ptr Structure
Equals Overload
Math.Gmp.Native Namespace


char_ptr.Equals Method (char_ptr)

char_ptrEquals Method (char_ptr)
Returns a value indicating whether this instance is equal to a specified char_ptr value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    char_ptr other
)
Public Function Equals (
    other As char_ptr
) As Boolean
public:
bool Equals(
    char_ptr other
)
member Equals :
        other : char_ptr -> bool

Parameters

other
Type: Math.Gmp.Nativechar_ptr
A char_ptr value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

char_ptr Structure
Equals Overload
Math.Gmp.Native Namespace


char_ptr.GetHashCode Method

char_ptrGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.ToIntPtr Method

char_ptrToIntPtr Method
Gets pointer to string in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
Pointer to string in unmanaged memory.
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.ToString Method

char_ptrToString Method
Gets the .NET string equivalent of the unmanaged string.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The .NET string equivalent of the unmanaged string.
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr Operators

char_ptr Operators

The char_ptr type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Equality Operator

char_ptrEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    char_ptr value1,
    char_ptr value2
)
Public Shared Operator = (
    value1 As char_ptr,
    value2 As char_ptr
) As Boolean
public:
static bool operator ==(
    char_ptr value1,
    char_ptr value2
)
static let inline (=)
        value1 : char_ptr *
        value2 : char_ptr  : bool

Parameters

value1
Type: Math.Gmp.Nativechar_ptr
A char_ptr value.
value2
Type: Math.Gmp.Nativechar_ptr
A char_ptr value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Inequality Operator

char_ptrInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    char_ptr value1,
    char_ptr value2
)
Public Shared Operator <> (
    value1 As char_ptr,
    value2 As char_ptr
) As Boolean
public:
static bool operator !=(
    char_ptr value1,
    char_ptr value2
)
static let inline (<>)
        value1 : char_ptr *
        value2 : char_ptr  : bool

Parameters

value1
Type: Math.Gmp.Nativechar_ptr
A char_ptr value.
value2
Type: Math.Gmp.Nativechar_ptr
A char_ptr value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr Fields

char_ptr Fields

The char_ptr type exposes the following members.

Fields
 | Name | Description
Public field | Pointer | Pointer to string in unmanaged memory.
 | Zero | Gets a null char_ptr.
Top
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Pointer Field

char_ptrPointer Field
Pointer to string in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr Pointer
Public Pointer As IntPtr
public:
IntPtr Pointer
val mutable Pointer: IntPtr

Field Value

Type: IntPtr
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


char_ptr.Zero Field

char_ptrZero Field
Gets a null char_ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly char_ptr Zero
Public Shared ReadOnly Zero As char_ptr
public:
static initonly char_ptr Zero
static val Zero: char_ptr

Field Value

Type: char_ptr
See Also

Reference

char_ptr Structure
Math.Gmp.Native Namespace


FILE Structure

FILE Structure
Represents a file stream.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct FILE
Public Structure FILE
public value class FILE
[<SealedAttribute>]
type FILE =  struct end

The FILE type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(FILE) | Returns a value indicating whether this instance is equal to a specified FILE value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | File pointer in unmanaged memory.
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace


FILE Methods

FILE Methods

The FILE type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(FILE) | Returns a value indicating whether this instance is equal to a specified FILE value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.)
Top
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE.Equals Method

FILEEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(FILE) | Returns a value indicating whether this instance is equal to a specified FILE value.
Top
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE.Equals Method (Object)

FILEEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of FILE and equals the value of this instance; otherwise, False.
See Also

Reference

FILE Structure
Equals Overload
Math.Gmp.Native Namespace


FILE.Equals Method (FILE)

FILEEquals Method (FILE)
Returns a value indicating whether this instance is equal to a specified FILE value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    FILE other
)
Public Function Equals (
    other As FILE
) As Boolean
public:
bool Equals(
    FILE other
)
member Equals :
        other : FILE -> bool

Parameters

other
Type: Math.Gmp.NativeFILE
A FILE value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

FILE Structure
Equals Overload
Math.Gmp.Native Namespace


FILE.GetHashCode Method

FILEGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE Operators

FILE Operators

The FILE type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE.Equality Operator

FILEEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    FILE value1,
    FILE value2
)
Public Shared Operator = (
    value1 As FILE,
    value2 As FILE
) As Boolean
public:
static bool operator ==(
    FILE value1,
    FILE value2
)
static let inline (=)
        value1 : FILE *
        value2 : FILE  : bool

Parameters

value1
Type: Math.Gmp.NativeFILE
A FILE value.
value2
Type: Math.Gmp.NativeFILE
A FILE value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE.Inequality Operator

FILEInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    FILE value1,
    FILE value2
)
Public Shared Operator <> (
    value1 As FILE,
    value2 As FILE
) As Boolean
public:
static bool operator !=(
    FILE value1,
    FILE value2
)
static let inline (<>)
        value1 : FILE *
        value2 : FILE  : bool

Parameters

value1
Type: Math.Gmp.NativeFILE
A FILE value.
value2
Type: Math.Gmp.NativeFILE
A FILE value.

Return Value

Type: Boolean
True if the two FILE are different, and False otherwise.
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE Fields

FILE Fields

The FILE type exposes the following members.

Fields
 | Name | Description
Public field | Value | File pointer in unmanaged memory.
Top
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


FILE.Value Field

FILEValue Field
File pointer in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr Value
Public Value As IntPtr
public:
IntPtr Value
val mutable Value: IntPtr

Field Value

Type: IntPtr
See Also

Reference

FILE Structure
Math.Gmp.Native Namespace


free_function Delegate

free_function Delegate
De-allocate the space pointed to by ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public delegate void free_function(
    void_ptr ptr,
    size_t size
)
Public Delegate Sub free_function (
    ptr As void_ptr,
    size As size_t
)
public delegate void free_function(
    void_ptr ptr,
    size_t size
)
type free_function =
    delegate of
        ptr : void_ptr *
        size : size_t -> unit

Parameters

ptr
Type: Math.Gmp.Nativevoid_ptr
Pointer to previously allocated block.
size
Type: Math.Gmp.Nativesize_t
Number of bytes of previously allocated block.
See Also

Reference

Math.Gmp.Native Namespace


gmp_lib Class

gmp_lib Class
Represents all of the functions of the GNU MP library.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativegmp_lib

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static class gmp_lib
Public NotInheritable Class gmp_lib
public ref class gmp_lib abstract sealed
[<AbstractClassAttribute>]
[<SealedAttribute>]
type gmp_lib =  class end

The gmp_lib type exposes the following members.

Properties
Name | Description
gmp_errno | Gets or sets the global GMP error number.
Top
Methods
Name | Description
_mpz_realloc | Change the space for integer to new_alloc limbs.
allocate | Return a pointer to newly allocated space with at least alloc_size bytes.
free(IntPtr) | Free the unmanaged memory at ptr.
free(char_ptr) | De-allocate the space pointed to by ptr.
free(gmp_randstate_t) | De-allocate the space pointed to by ptr.
free(mp_ptr) | De-allocate the space pointed to by ptrs.
free(void_ptr) | De-allocate the space pointed to by ptr.
free(void_ptr, size_t) | De-allocate the space pointed to by ptr.
gmp_asprintf | Form a null-terminated string in a block of memory obtained from the current memory allocation function.
gmp_fprintf | Print to the stream fp.
gmp_fscanf | Read from the stream fp.
gmp_printf | Print to the standard output stdout.
gmp_randclear | Free all memory occupied by state.
gmp_randinit_default | Initialize state with a default algorithm.
gmp_randinit_lc_2exp | Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.
gmp_randinit_lc_2exp_size | Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp.
gmp_randinit_mt | Initialize state for a Mersenne Twister algorithm.
gmp_randinit_set | Initialize rop with a copy of the algorithm and state from op.
gmp_randseed | Set an initial seed value into state.
gmp_randseed_ui | Set an initial seed value into state.
gmp_scanf | Read from the standard input stdin.
gmp_snprintf | Form a null-terminated string in buf.
gmp_sprintf | Form a null-terminated string in buf.
gmp_sscanf | Read from a null-terminated string s.
gmp_urandomb_ui | Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.
gmp_urandomm_ui | Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.
gmp_vasprintf | Form a null-terminated string in a block of memory obtained from the current memory allocation function.
gmp_vfprintf | Print to the stream fp.
gmp_vfscanf | Read from the stream fp.
gmp_vprintf | Print to the standard output stdout.
gmp_vscanf | Read from the standard input stdin.
gmp_vsnprintf | Form a null-terminated string in buf.
gmp_vsprintf | Form a null-terminated string in buf.
gmp_vsscanf | Read from a null-terminated string s.
mp_get_memory_functions | Get the current allocation functions, storing function pointers to the locations given by the arguments.
mp_set_memory_functions | Replace the current allocation functions from the arguments.
mpf_abs | Set rop to | op |.
mpf_add | Set rop to op1 + op2.
mpf_add_ui | Set rop to op1 + op2.
mpf_ceil | Set rop to op rounded to the next higher integer.
mpf_clear | Free the space occupied by x.
mpf_clears | Free the space occupied by a NULL-terminated list of mpf_t variables.
mpf_cmp | Compare op1 and op2.
mpf_cmp_d | Compare op1 and op2.
mpf_cmp_si | Compare op1 and op2.
mpf_cmp_ui | Compare op1 and op2.
mpf_cmp_z | Compare op1 and op2.
mpf_div | Set rop to op1 / op2.
mpf_div_2exp | Set rop to op1 / 2^op2.
mpf_div_ui | Set rop to op1 / op2.
mpf_fits_sint_p | Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
mpf_fits_slong_p | Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
mpf_fits_sshort_p | Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
mpf_fits_uint_p | Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
mpf_fits_ulong_p | Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
mpf_fits_ushort_p | Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
mpf_floor | Set rop to op rounded to the next lower integer.
mpf_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpf_get_d_2exp | Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.
mpf_get_default_prec | Return the default precision actually used.
mpf_get_prec | Return the current precision of op, in bits.
mpf_get_si | Convert op to a 32-bit integer, truncating any fraction part.
mpf_get_str(char_ptr, mp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
mpf_get_str(char_ptr, ptrmp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
mpf_get_ui | Convert op to an unsigned 32-bit integer, truncating any fraction part.
mpf_init | Initialize x to 0.
mpf_init_set | Initialize rop and set its value from op.
mpf_init_set_d | Initialize rop and set its value from op.
mpf_init_set_si | Initialize rop and set its value from op.
mpf_init_set_str | Initialize rop and set its value from the string in str.
mpf_init_set_ui | Initialize rop and set its value from op.
mpf_init2 | Initialize x to 0 and set its precision to be at least prec bits.
mpf_inits | Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.
mpf_inp_str | Read a string in base base from stream, and put the read float in rop.
mpf_integer_p | Return non-zero if op is an integer.
mpf_mul | Set rop to op1 * op2.
mpf_mul_2exp | Set rop to op1 * 2^op2.
mpf_mul_ui | Set rop to op1 * op2.
mpf_neg | Set rop to -op.
mpf_out_str | Print op to stream, as a string of digits.
mpf_pow_ui | Set rop to op1^op2.
mpf_random2 | Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.
mpf_reldiff | Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.
mpf_set | Set the value of rop from op.
mpf_set_d | Set the value of rop from op.
mpf_set_default_prec | Set the default precision to be at least prec bits.
mpf_set_prec | Set the precision of rop to be at least prec bits.
mpf_set_prec_raw | Set the precision of rop to be at least prec bits, without changing the memory allocated.
mpf_set_q | Set the value of rop from op.
mpf_set_si | Set the value of rop from op.
mpf_set_str | Set the value of rop from the string in str.
mpf_set_ui | Set the value of rop from op.
mpf_set_z | Set the value of rop from op.
mpf_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpf_size | Return the number of limbs currently in use.
mpf_sqrt | Set rop to the square root of op.
mpf_sqrt_ui | Set rop to the square root of op.
mpf_sub | Set rop to op1 - op2.
mpf_sub_ui | Set rop to op1 - op2.
mpf_swap | Swap rop1 and rop2 efficiently.
mpf_trunc | Set rop to op rounded to the integer towards zero.
mpf_ui_div | Set rop to op1 / op2.
mpf_ui_sub | Set rop to op1 - op2.
mpf_urandomb | Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.
mpn_add | Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.
mpn_add_1 | Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.
mpn_add_n | Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.
mpn_addmul_1 | Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.
mpn_and_n | Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_andn_n | Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
mpn_cmp | Compare {s1p, n} and {s2p, n}.
mpn_cnd_add_n | If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
mpn_cnd_sub_n | If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
mpn_cnd_swap | If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
mpn_com | Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.
mpn_copyd | Copy from {s1p, n} to {rp, n}, decreasingly.
mpn_copyi | Copy from {s1p, n} to {rp, n}, increasingly.
mpn_divexact_1 | Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.
mpn_divexact_by3 | Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
mpn_divexact_by3c | Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
mpn_divmod_1 | Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
mpn_divrem_1 | Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
mpn_gcd | Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
mpn_gcd_1 | Return the greatest common divisor of {xp, xn} and ylimb.
mpn_gcdext(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
mpn_gcdext(mp_ptr, mp_ptr, ptrmp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
mpn_get_str | Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.
mpn_hamdist | Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.
mpn_ior_n | Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_iorn_n | Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
mpn_lshift | Shift {sp, n} left by count bits, and write the result to {rp, n}.
mpn_mod_1 | Divide {s1p, s1n} by s2limb, and return the remainder.
mpn_mul | Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.
mpn_mul_1 | Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.
mpn_mul_n | Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.
mpn_nand_n | Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_neg | Perform the negation of {sp, n}, and write the result to {rp, n}.
mpn_nior_n | Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_perfect_power_p | Return non-zero iff {sp, n} is a perfect power.
mpn_perfect_square_p | Return non-zero iff {s1p, n} is a perfect square.
mpn_popcount | Count the number of set bits in {s1p, n}.
mpn_random | Generate a random number of length r1n and store it at r1p.
mpn_random2 | Generate a random number of length r1n and store it at r1p.
mpn_rshift | Shift {sp, n} right by count bits, and write the result to {rp, n}.
mpn_scan0 | Scan s1p from bit position bit for the next clear bit.
mpn_scan1 | Scan s1p from bit position bit for the next set bit.
mpn_sec_add_1 | Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
mpn_sec_add_1_itch | Return the scratch space in number of limbs required by the function mpn_sec_add_1.
mpn_sec_div_qr | Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.
mpn_sec_div_qr_itch | Return the scratch space in number of limbs required by the function mpn_sec_div_qr.
mpn_sec_div_r | Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
mpn_sec_div_r_itch | Return the scratch space in number of limbs required by the function mpn_sec_div_r.
mpn_sec_invert | Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.
mpn_sec_invert_itch | Return the scratch space in number of limbs required by the function mpn_sec_invert.
mpn_sec_mul | Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.
mpn_sec_mul_itch | Return the scratch space in number of limbs required by the function mpn_sec_mul.
mpn_sec_powm | Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.
mpn_sec_powm_itch | Return the scratch space in number of limbs required by the function mpn_sec_powm.
mpn_sec_sqr | Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.
mpn_sec_sqr_itch | Return the scratch space in number of limbs required by the function mpn_sec_sqr.
mpn_sec_sub_1 | Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
mpn_sec_sub_1_itch | Return the scratch space in number of limbs required by the function mpn_sec_sub_1.
mpn_sec_tabselect | Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.
mpn_set_str | Convert bytes {str, strsize} in the given base to limbs at rp.
mpn_sizeinbase | Return the size of {xp, n} measured in number of digits in the given base.
mpn_sqr | Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.
mpn_sqrtrem | Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.
mpn_sub | Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.
mpn_sub_1 | Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.
mpn_sub_n | Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.
mpn_submul_1 | Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.
mpn_tdiv_qr | Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.
mpn_xnor_n | Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_xor_n | Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_zero | Zero {rp, n}.
mpn_zero_p | Test {sp, n} and return 1 if the operand is zero, 0 otherwise.
mpq_abs | Set rop to the absolute value of op.
mpq_add | Set sum to addend1 + addend2.
mpq_canonicalize | Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.
mpq_clear | Free the space occupied by x.
mpq_clears | Free the space occupied by a NULL-terminated list of mpq_t variables.
mpq_cmp | Compare op1 and op2.
mpq_cmp_si | Compare op1 and num2 / den2.
mpq_cmp_ui | Compare op1 and num2 / den2.
mpq_cmp_z | Compare op1 and op2.
mpq_denref | Return a reference to the denominator op.
mpq_div | Set quotient to dividend / divisor.
mpq_div_2exp | Set rop to op1 / 2^op2.
mpq_equal | Return non-zero if op1 and op2 are equal, zero if they are non-equal.
mpq_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpq_get_den | Set denominator to the denominator of rational.
mpq_get_num | Set numerator to the numerator of rational.
mpq_get_str | Convert op to a string of digits in base base.
mpq_init | Initialize x and set it to 0/1.
mpq_inits | Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.
mpq_inp_str | Read a string of digits from stream and convert them to a rational in rop.
mpq_inv | Set inverted_number to 1 / number.
mpq_mul | Set product to multiplier * multiplicand.
mpq_mul_2exp | Set rop to op1 * 2*op2.
mpq_neg | Set negated_operand to -operand.
mpq_numref | Return a reference to the numerator op.
mpq_out_str | Output op on stdio stream stream, as a string of digits in base base.
mpq_set | Assign rop from op.
mpq_set_d | Set rop to the value of op. There is no rounding, this conversion is exact.
mpq_set_den | Set the denominator of rational to denominator.
mpq_set_f | Set rop to the value of op. There is no rounding, this conversion is exact.
mpq_set_num | Set the numerator of rational to numerator.
mpq_set_si | Set the value of rop to op1 / op2.
mpq_set_str | Set rop from a null-terminated string str in the given base.
mpq_set_ui | Set the value of rop to op1 / op2.
mpq_set_z | Assign rop from op.
mpq_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpq_sub | Set difference to minuend - subtrahend.
mpq_swap | Swap the values rop1 and rop2 efficiently.
mpz_2fac_ui | Set rop to the double-factorial n!!.
mpz_abs | Set rop to the absolute value of op.
mpz_add | Set rop to op1 + op2.
mpz_add_ui | Set rop to op1 + op2.
mpz_addmul | Set rop to rop + op1 * op2.
mpz_addmul_ui | Set rop to rop + op1 * op2.
mpz_and | Set rop to op1 bitwise-and op2.
mpz_bin_ui | Compute the binomial coefficient n over k and store the result in rop.
mpz_bin_uiui | Compute the binomial coefficient n over k and store the result in rop.
mpz_cdiv_q | Set the quotient q to ceiling(n / d).
mpz_cdiv_q_2exp | Set the quotient q to ceiling(n / 2^b).
mpz_cdiv_q_ui | Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.
mpz_cdiv_qr | Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.
mpz_cdiv_qr_ui | Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.
mpz_cdiv_r | Set the remainder r to n - q * d where q = ceiling(n / d).
mpz_cdiv_r_2exp | Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).
mpz_cdiv_r_ui | Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.
mpz_cdiv_ui | Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).
mpz_clear | Free the space occupied by x.
mpz_clears | Free the space occupied by a NULL-terminated list of mpz_t variables.
mpz_clrbit | Clear bit bit_index in rop.
mpz_cmp | Compare op1 and op2.
mpz_cmp_d | Compare op1 and op2.
mpz_cmp_si | Compare op1 and op2.
mpz_cmp_ui | Compare op1 and op2.
mpz_cmpabs | Compare the absolute values of op1 and op2.
mpz_cmpabs_d | Compare the absolute values of op1 and op2.
mpz_cmpabs_ui | Compare the absolute values of op1 and op2.
mpz_com | Set rop to the one’s complement of op.
mpz_combit | Complement bit bit_index in rop.
mpz_congruent_2exp_p | Return non-zero if n is congruent to c modulo 2^b.
mpz_congruent_p | Return non-zero if n is congruent to c modulo d.
mpz_congruent_ui_p | Return non-zero if n is congruent to c modulo d.
mpz_divexact | Set q to n / d when it is known in advance that d divides n.
mpz_divexact_ui | Set q to n / d when it is known in advance that d divides n.
mpz_divisible_2exp_p | Return non-zero if n is exactly divisible by 2^b.
mpz_divisible_p | Return non-zero if n is exactly divisible by d.
mpz_divisible_ui_p | Return non-zero if n is exactly divisible by d.
mpz_even_p | Determine whether op is even.
mpz_export(void_ptr, ptrsize_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
mpz_export(void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
mpz_fac_ui | Set rop to the factorial n!.
mpz_fdiv_q | Set the quotient q to floor(n / d).
mpz_fdiv_q_2exp | Set the quotient q to floor(n / 2^b).
mpz_fdiv_q_ui | Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.
mpz_fdiv_qr | Set the quotient q to floor(n / d), and set the remainder r to n - q * d.
mpz_fdiv_qr_ui | Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.
mpz_fdiv_r | Set the remainder r to n - q * d where q = floor(n / d).
mpz_fdiv_r_2exp | Set the remainder r to n - q * 2^b where q = floor(n / 2^b).
mpz_fdiv_r_ui | Set the remainder r to n - q * d where q = floor(n / d), and return | r |.
mpz_fdiv_ui | Return the remainder | r | where r = n - q * d, and where q = floor(n / d).
mpz_fib_ui | Sets fn to to F[n], the n’th Fibonacci number.
mpz_fib2_ui | Sets fn to F[n], and fnsub1 to F[n - 1].
mpz_fits_sint_p | Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
mpz_fits_slong_p | Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
mpz_fits_sshort_p | Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
mpz_fits_uint_p | Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
mpz_fits_ulong_p | Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
mpz_fits_ushort_p | Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
mpz_gcd | Set rop to the greatest common divisor of op1 and op2.
mpz_gcd_ui | Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.
mpz_gcdext | Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.
mpz_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpz_get_d_2exp | Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
mpz_get_si | Return the value of op as an signed long.
mpz_get_str | Convert op to a string of digits in base base.
mpz_get_ui | Return the value of op as an unsigned long.
mpz_getlimbn | Return limb number n from op.
mpz_hamdist | Return the hamming distance between the two operands.
mpz_import | Set rop from an array of word data at op.
mpz_init | Initialize x, and set its value to 0.
mpz_init_set | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_d | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_si | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_str | Initialize rop and set its value like mpz_set_str.
mpz_init_set_ui | Initialize rop with limb space and set the initial numeric value from op.
mpz_init2 | Initialize x, with space for n-bit numbers, and set its value to 0.
mpz_inits | Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.
mpz_inp_raw | Input from stdio stream stream in the format written by mpz_out_raw, and put the result in rop.
mpz_inp_str | Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.
mpz_invert | Compute the inverse of op1 modulo op2 and put the result in rop.
mpz_ior | Set rop to op1 bitwise inclusive-or op2.
mpz_jacobi | Calculate the Jacobi symbol (a/b).
mpz_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_kronecker_si | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_kronecker_ui | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_lcm | Set rop to the least common multiple of op1 and op2.
mpz_lcm_ui | Set rop to the least common multiple of op1 and op2.
mpz_legendre | Calculate the Legendre symbol (a/p).
mpz_limbs_finish | Updates the internal size field of x.
mpz_limbs_modify | Return a pointer to the limb array of x, intended for write access.
mpz_limbs_read | Return a pointer to the limb array representing the absolute value of x.
mpz_limbs_write | Return a pointer to the limb array of x, intended for write access.
mpz_lucnum_ui | Sets ln to to L[n], the n’th Lucas number.
mpz_lucnum2_ui | Sets ln to L[n], and lnsub1 to L[n - 1].
mpz_mfac_uiui | Set rop to the m-multi-factorial n!^(m)n.
mpz_millerrabin | An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.
mpz_mod | Set r to n mod d.
mpz_mod_ui | Set r to n mod d.
mpz_mul | Set rop to op1 * op2.
mpz_mul_2exp | Set rop to op1 * 2^op2.
mpz_mul_si | Set rop to op1 * op2.
mpz_mul_ui | Set rop to op1 * op2.
mpz_neg | Set rop to -op.
mpz_nextprime | Set rop to the next prime greater than op.
mpz_odd_p | Determine whether op is odd.
mpz_out_raw | Output op on stdio stream stream, in raw binary format.
mpz_out_str | Output op on stdio stream stream, as a string of digits in base base.
mpz_perfect_power_p | Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
mpz_perfect_square_p | Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.
mpz_popcount | Return the population count of op.
mpz_pow_ui | Set rop to base^exp. The case 0^0 yields 1.
mpz_powm | Set rop to (base^exp) modulo mod.
mpz_powm_sec | Set rop to (base^exp) modulo mod.
mpz_powm_ui | Set rop to (base^exp) modulo mod.
mpz_primorial_ui | Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.
mpz_probab_prime_p | Determine whether n is prime.
mpz_random | Generate a random integer of at most max_size limbs.
mpz_random2 | Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.
mpz_realloc2 | Change the space allocated for x to n bits.
mpz_remove | Remove all occurrences of the factor f from op and store the result in rop.
mpz_roinit_n | Special initialization of x, using the given limb array and size.
mpz_root | Set rop to the truncated integer part of the nth root of op.
mpz_rootrem | Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.
mpz_rrandomb | Generate a random integer with long strings of zeros and ones in the binary representation.
mpz_scan0 | Scan op for 0 bit.
mpz_scan1 | Scan op for 1 bit.
mpz_set | Set the value of rop from op.
mpz_set_d | Set the value of rop from op.
mpz_set_f | Set the value of rop from op.
mpz_set_q | Set the value of rop from op.
mpz_set_si | Set the value of rop from op.
mpz_set_str | Set the value of rop from str, a null-terminated C string in base base.
mpz_set_ui | Set the value of rop from op.
mpz_setbit | Set bit bit_index in rop.
mpz_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpz_si_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_size | Return the size of op measured in number of limbs.
mpz_sizeinbase | Return the size of op measured in number of digits in the given base.
mpz_sqrt | Set rop to the truncated integer part of the square root of op.
mpz_sqrtrem | Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.
mpz_sub | Set rop to op1 - op2.
mpz_sub_ui | Set rop to op1 - op2.
mpz_submul | Set rop to rop - op1 * op2.
mpz_submul_ui | Set rop to rop - op1 * op2.
mpz_swap | Swap the values rop1 and rop2 efficiently.
mpz_tdiv_q | Set the quotient q to trunc(n / d).
mpz_tdiv_q_2exp | Set the quotient q to trunc(n / 2^b).
mpz_tdiv_q_ui | Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.
mpz_tdiv_qr | Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.
mpz_tdiv_qr_ui | Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.
mpz_tdiv_r | Set the remainder r to n - q * d where q = trunc(n / d).
mpz_tdiv_r_2exp | Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).
mpz_tdiv_r_ui | Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.
mpz_tdiv_ui | Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).
mpz_tstbit | Test bit bit_index in op and return 0 or 1 accordingly.
mpz_ui_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_ui_pow_ui | Set rop to base^exp. The case 0^0 yields 1.
mpz_ui_sub | Set rop to op1 - op2.
mpz_urandomb | Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.
mpz_urandomm | Generate a uniform random integer in the range 0 to n - 1, inclusive.
mpz_xor | Set rop to op1 bitwise exclusive-or op2.
reallocate | Resize a previously allocated block ptr of old_size bytes to be new_size bytes.
ZeroMemory | The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
Top
Fields
Name | Description
gmp_version | The GMP version number in the form “i.j.k”. This release is "6.1.2".
mp_bits_per_limb | The number of bits per limb.
mp_bytes_per_limb | The number of bytes per limb.
mp_uint_per_limb | The number of 32-bit, unsigned integers per limb.
Top
Remarks

Functions Categories

Global Variable and Constants:

  • gmp_errno - Gets or sets the global GMP error number.
  • gmp_version - The GMP version number in the form “i.j.k”. This release is "6.1.2".
  • mp_bits_per_limb - The number of bits per limb.
  • mp_bytes_per_limb - The number of bytes per limb.
  • mp_uint_per_limb - The number of 32-bit, unsigned integers per limb.

Integer Functions:

Initializing Integers:

  • mpz_init - Initialize x, and set its value to 0.
  • mpz_inits - Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.
  • mpz_init2 - Initialize x, with space for n-bit numbers, and set its value to 0.
  • mpz_clear - Free the space occupied by x.
  • mpz_clears - Free the space occupied by a NULL-terminated list of mpz_t variables.
  • mpz_realloc2 - Change the space allocated for x to n bits.

Assigning Integers:

  • mpz_set - Set the value of rop from op.
  • mpz_set_ui - Set the value of rop from op.
  • mpz_set_si - Set the value of rop from op.
  • mpz_set_d - Set the value of rop from op.
  • mpz_set_q - Set the value of rop from op.
  • mpz_set_f - Set the value of rop from op.
  • mpz_set_str - Set the value of rop from str, a null-terminated C string in base base.
  • mpz_swap - Swap the values rop1 and rop2 efficiently.

Simultaneous Integer Init & Assign:

  • mpz_init_set - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_ui - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_si - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_d - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_set_str - Set the value of rop from str, a null-terminated C string in base base.

Converting Integers:

  • mpz_get_ui - Return the value of op as an unsigned long.
  • mpz_get_si - Return the value of op as an signed long.
  • mpz_get_d - Convert op to a double, truncating if necessary (i.e. rounding towards zero).
  • mpz_get_d_2exp - Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
  • mpz_get_str - Convert op to a string of digits in base base.

Integer Arithmetic:

  • mpz_add - Set rop to op1 + op2.
  • mpz_add_ui - Set rop to op1 + op2.
  • mpz_sub - Set rop to op1 - op2.
  • mpz_sub_ui - Set rop to op1 - op2.
  • mpz_ui_sub - Set rop to op1 - op2.
  • mpz_mul - Set rop to op1 * op2.
  • mpz_mul_si - Set rop to op1 * op2.
  • mpz_mul_ui - Set rop to op1 * op2.
  • mpz_addmul - Set rop to rop + op1 * op2.
  • mpz_addmul_ui - Set rop to rop + op1 * op2.
  • mpz_submul - Set rop to rop - op1 * op2.
  • mpz_submul_ui - Set rop to rop - op1 * op2.
  • mpz_mul_2exp - Set rop to op1 * 2^op2.
  • mpz_neg - Set rop to -op.
  • mpz_abs - Set rop to the absolute value of op.

Integer Division:

  • mpz_cdiv_q - Set the quotient q to ceiling(n / d).
  • mpz_cdiv_r - Set the remainder r to n - q * d where q = ceiling(n / d).
  • mpz_cdiv_qr - Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.
  • mpz_cdiv_q_ui - Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.
  • mpz_cdiv_r_ui - Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.
  • mpz_cdiv_qr_ui - Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_cdiv_ui - Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).
  • mpz_cdiv_q_2exp - Set the quotient q to ceiling(n / 2^b).
  • mpz_cdiv_r_2exp - Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).
  • mpz_fdiv_q - Set the quotient q to floor(n / d).
  • mpz_fdiv_r - Set the remainder r to n - q * d where q = floor(n / d).
  • mpz_fdiv_qr - Set the quotient q to floor(n / d), and set the remainder r to n - q * d.
  • mpz_fdiv_q_ui - Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.
  • mpz_fdiv_r_ui - Set the remainder r to n - q * d where q = floor(n / d), and return | r |.
  • mpz_fdiv_qr_ui - Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_fdiv_ui - Return the remainder | r | where r = n - q * d, and where q = floor(n / d).
  • mpz_fdiv_q_2exp - Set the quotient q to floor(n / 2^b).
  • mpz_fdiv_r_2exp - Set the remainder r to n - q * 2^b where q = floor(n / 2^b).
  • mpz_tdiv_q - Set the quotient q to trunc(n / d).
  • mpz_tdiv_r - Set the remainder r to n - q * d where q = trunc(n / d).
  • mpz_tdiv_qr - Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.
  • mpz_tdiv_q_ui - Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.
  • mpz_tdiv_r_ui - Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.
  • mpz_tdiv_qr_ui - Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_tdiv_ui - Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).
  • mpz_tdiv_q_2exp - Set the quotient q to trunc(n / 2^b).
  • mpz_tdiv_r_2exp - Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).
  • mpz_mod - Set r to n mod d.
  • mpz_mod_ui - Set r to n mod d.
  • mpz_divexact - Set q to n / d when it is known in advance that d divides n.
  • mpz_divexact_ui - Set q to n / d when it is known in advance that d divides n.
  • mpz_divisible_p - Return non-zero if n is exactly divisible by d.
  • mpz_divisible_ui_p - Return non-zero if n is exactly divisible by d.
  • mpz_divisible_2exp_p - Return non-zero if n is exactly divisible by 2^b.
  • mpz_congruent_p - Return non-zero if n is congruent to c modulo d.
  • mpz_congruent_ui_p - Return non-zero if n is congruent to c modulo d.
  • mpz_congruent_2exp_p - Return non-zero if n is congruent to c modulo 2^b.

Integer Exponentiation:

  • mpz_powm - Set rop to (base^exp) modulo mod.
  • mpz_powm_ui - Set rop to (base^exp) modulo mod.
  • mpz_powm_sec - Set rop to (base^exp) modulo mod.
  • mpz_pow_ui - Set rop to base^exp. The case 0^0 yields 1.
  • mpz_ui_pow_ui - Set rop to base^exp. The case 0^0 yields 1.

Integer Roots:

  • mpz_root - Set rop to the truncated integer part of the nth root of op.
  • mpz_rootrem - Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.
  • mpz_sqrt - Set rop to the truncated integer part of the square root of op.
  • mpz_sqrtrem - Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.
  • mpz_perfect_power_p - Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
  • mpz_perfect_square_p - Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.

Number Theoretic Functions:

  • mpz_probab_prime_p - Determine whether n is prime.
  • mpz_nextprime - Set rop to the next prime greater than op.
  • mpz_gcd - Set rop to the greatest common divisor of op1 and op2.
  • mpz_gcd_ui - Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.
  • mpz_gcdext - Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.
  • mpz_lcm - Set rop to the least common multiple of op1 and op2.
  • mpz_lcm_ui - Set rop to the least common multiple of op1 and op2.
  • mpz_invert - Compute the inverse of op1 modulo op2 and put the result in rop.
  • mpz_jacobi - Calculate the Jacobi symbol (a/b).
  • mpz_legendre - Calculate the Legendre symbol (a/p).
  • mpz_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_kronecker_si - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_kronecker_ui - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_si_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_ui_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_remove - Remove all occurrences of the factor f from op and store the result in rop.
  • mpz_fac_ui - Set rop to the factorial n!.
  • mpz_2fac_ui - Set rop to the double-factorial n!!.
  • mpz_mfac_uiui - Set rop to the m-multi-factorial n!^(m)n.
  • mpz_primorial_ui - Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.
  • mpz_bin_ui - Compute the binomial coefficient n over k and store the result in rop.
  • mpz_bin_uiui - Compute the binomial coefficient n over k and store the result in rop.
  • mpz_fib_ui - Sets fn to to F[n], the n’th Fibonacci number.
  • mpz_fib2_ui - Sets fn to F[n], and fnsub1 to F[n - 1].
  • mpz_lucnum_ui - Sets ln to to L[n], the n’th Lucas number.
  • mpz_lucnum2_ui - Sets ln to L[n], and lnsub1 to L[n - 1].
  • mpz_millerrabin - An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.

Integer Comparisons:

  • mpz_cmp - Compare op1 and op2.
  • mpz_cmp_d - Compare op1 and op2.
  • mpz_cmp_si - Compare op1 and op2.
  • mpz_cmp_ui - Compare op1 and op2.
  • mpz_cmpabs - Compare the absolute values of op1 and op2.
  • mpz_cmpabs_d - Compare the absolute values of op1 and op2.
  • mpz_cmpabs_ui - Compare the absolute values of op1 and op2.
  • mpz_sgn - Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

Integer Logic and Bit Fiddling:

  • mpz_and - Set rop to op1 bitwise-and op2.
  • mpz_ior - Set rop to op1 bitwise inclusive-or op2.
  • mpz_xor - Set rop to op1 bitwise exclusive-or op2.
  • mpz_com - Set rop to the one’s complement of op.
  • mpz_popcount - Return the population count of op.
  • mpz_hamdist - Return the hamming distance between the two operands.
  • mpz_scan0 - Scan op for 0 bit.
  • mpz_scan1 - Scan op for 1 bit.
  • mpz_setbit - Set bit bit_index in rop.
  • mpz_clrbit - Clear bit bit_index in rop.
  • mpz_combit - Complement bit bit_index in rop.
  • mpz_tstbit - Test bit bit_index in op and return 0 or 1 accordingly.

I/O of Integers:

  • mpz_out_str - Output op on stdio stream stream, as a string of digits in base base.
  • mpz_inp_str - Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.
  • mpz_out_raw - Output op on stdio stream stream, in raw binary format.
  • mpz_out_raw, and put the result in rop.

Integer Random Numbers:

  • mpz_urandomb - Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.
  • mpz_urandomm - Generate a uniform random integer in the range 0 to n - 1, inclusive.
  • mpz_rrandomb - Generate a random integer with long strings of zeros and ones in the binary representation.
  • mpz_random - Generate a random integer of at most max_size limbs.
  • mpz_random2 - Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Integer Import and Export:

  • mpz_import - Set rop from an array of word data at op.
  • mpz_export - Fill rop with word data from op.

Miscellaneous Integer Functions:

  • mpz_fits_sint_p - Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
  • mpz_fits_slong_p - Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
  • mpz_fits_sshort_p - Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
  • mpz_fits_uint_p - Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
  • mpz_fits_ulong_p - Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
  • mpz_fits_ushort_p - Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
  • mpz_sizeinbase - Return the size of op measured in number of digits in the given base.
  • mpz_even_p - Determine whether op is even.
  • mpz_odd_p - Determine whether op is odd.

Integer Special Functions:

  • _mpz_realloc - Change the space for integer to new_alloc limbs.
  • mpz_getlimbn - Return limb number n from op.
  • mpz_size - Return the size of op measured in number of limbs.
  • mpz_limbs_read - Return a pointer to the limb array representing the absolute value of x.
  • mpz_limbs_write - Return a pointer to the limb array of x, intended for write access.
  • mpz_limbs_modify - Return a pointer to the limb array of x, intended for write access.
  • mpz_limbs_finish - Updates the internal size field of x.
  • mpz_roinit_n - Special initialization of x, using the given limb array and size.

Rational Number Functions:

Initializing Rationals:

  • mpq_canonicalize - Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.
  • mpq_init - Initialize x and set it to 0/1.
  • mpq_inits - Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.
  • mpq_clear - Free the space occupied by x.
  • mpq_clears - Free the space occupied by a NULL-terminated list of mpq_t variables.
  • mpq_set - Assign rop from op.
  • mpq_set_z - Assign rop from op.
  • mpq_set_ui - Set the value of rop to op1 / op2.
  • mpq_set_si - Set the value of rop to op1 / op2.
  • mpq_set_str - Set rop from a null-terminated string str in the given base.
  • mpq_swap - Swap the values rop1 and rop2 efficiently.

Rational Conversions:

  • mpq_get_d - Convert op to a System.Double, truncating if necessary (i.e. rounding towards zero).
  • mpq_set_d - Set rop to the value of op. There is no rounding, this conversion is exact.
  • mpq_set_f - Set rop to the value of op. There is no rounding, this conversion is exact.
  • mpq_get_str - Convert op to a string of digits in base base.

Rational Arithmetic:

  • mpq_add - Set sum to addend1 + addend2.
  • mpq_sub - Set difference to minuend - subtrahend.
  • mpq_mul - Set product to multiplier * multiplicand.
  • mpq_mul_2exp - Set rop to op1 * 2^op2.
  • mpq_div - Set quotient to dividend / divisor.
  • mpq_div_2exp - Set rop to op1 / 2^op2.
  • mpq_neg - Set negated_operand to -operand.
  • mpq_abs - Set rop to the absolute value of op.
  • mpq_inv - Set inverted_number to 1 / number.

Comparing Rationals:

  • mpq_cmp - Compare op1 and op2.
  • mpq_cmp_z - Compare op1 and op2.
  • mpq_cmp_ui - Compare op1 and num2 / den2.
  • mpq_cmp_si - Compare op1 and num2 / den2.
  • mpq_sgn - Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
  • mpq_equal - Return non-zero if op1 and op2 are equal, zero if they are non-equal.

Applying Integer Functions:

  • mpq_numref - Return a reference to the numerator op.
  • mpq_denref - Return a reference to the denominator op.
  • mpq_get_num - Set numerator to the numerator of rational.
  • mpq_get_den - Set denominator to the denominator of rational.
  • mpq_set_num - Set the numerator of rational to numerator.
  • mpq_set_den - Set the denominator of rational to denominator.

I/O of Rationals:

  • mpq_out_str - Output op on stdio stream stream, as a string of digits in base base.
  • mpq_inp_str - Read a string of digits from stream and convert them to a rational in rop.

Floating-point Functions:

Initializing Floats:

  • mpf_set_default_prec - Set the default precision to be at least prec bits.
  • mpf_get_default_prec - Return the default precision actually used.
  • mpf_init - Initialize x to 0.
  • mpf_init2 - Initialize x to 0 and set its precision to be at least prec bits.
  • mpf_inits - Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.
  • mpf_clear - Free the space occupied by x.
  • mpf_clears - Free the space occupied by a NULL-terminated list of mpf_t variables.
  • mpf_get_prec - Return the current precision of op, in bits.
  • mpf_set_prec - Set the precision of rop to be at least prec bits.
  • mpf_set_prec_raw - Set the precision of rop to be at least prec bits, without changing the memory allocated.
  • mpf_size - Return the number of limbs currently in use.

Assigning Floats:

  • mpf_set - Set the value of rop from op.
  • mpf_set_ui - Set the value of rop from op.
  • mpf_set_si - Set the value of rop from op.
  • mpf_set_d - Set the value of rop from op.
  • mpf_set_z - Set the value of rop from op.
  • mpf_set_q - Set the value of rop from op.
  • mpf_set_str - Set the value of rop from the string in str.
  • mpf_swap - Swap rop1 and rop2 efficiently.

Simultaneous Float Init & Assign:

  • mpf_init_set - Initialize rop and set its value from op.
  • mpf_init_set_ui - Initialize rop and set its value from op.
  • mpf_init_set_si - Initialize rop and set its value from op.
  • mpf_init_set_d - Initialize rop and set its value from op.
  • mpf_init_set_str - Initialize rop and set its value from the string in str.

Converting Floats:

  • mpf_get_d - Convert op to a System.Double, truncating if necessary (i.e. rounding towards zero).
  • mpf_get_d_2exp - Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.
  • mpf_get_si - Convert op to a 32-bit integer, truncating any fraction part.
  • mpf_get_ui - Convert op to an unsigned 32-bit integer, truncating any fraction part.
  • mpf_get_str - Convert op to a string of digits in base base.

Float Arithmetic:

  • mpf_add - Set rop to op1 + op2.
  • mpf_add_ui - Set rop to op1 + op2.
  • mpf_sub - Set rop to op1 - op2.
  • mpf_ui_sub - Set rop to op1 - op2.
  • mpf_sub_ui - Set rop to op1 - op2.
  • mpf_mul - Set rop to op1 * op2.
  • mpf_mul_ui - Set rop to op1 * op2.
  • mpf_div - Set rop to op1 / op2.
  • mpf_ui_div - Set rop to op1 / op2.
  • mpf_div_ui - Set rop to op1 / op2.
  • mpf_sqrt - Set rop to the square root of op.
  • mpf_sqrt_ui - Set rop to the square root of op.
  • mpf_pow_ui - Set rop to op1^op2.
  • mpf_neg - Set rop to -op.
  • mpf_abs - Set rop to | op |.
  • mpf_mul_2exp - Set rop to op1 * 2^op2.
  • mpf_div_2exp - Set rop to op1 / 2^op2.

Float Comparison:

  • mpf_cmp - Compare op1 and op2.
  • mpf_cmp_z - Compare op1 and op2.
  • mpf_cmp_d - Compare op1 and op2.
  • mpf_cmp_ui - Compare op1 and op2.
  • mpf_cmp_si - Compare op1 and op2.
  • mpf_reldiff - Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.
  • mpf_sgn - Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

I/O of Floats:

  • mpf_out_str - Print op to stream, as a string of digits.
  • mpf_inp_str - Read a string in base base from stream, and put the read float in rop.

Miscellaneous Float Functions:

  • mpf_ceil - Set rop to op rounded to the next higher integer.
  • mpf_floor - Set rop to op rounded to the next lower integer.
  • mpf_trunc - Set rop to op rounded to the integer towards zero.
  • mpf_integer_p - Return non-zero if op is an integer.
  • mpf_fits_ulong_p - Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
  • mpf_fits_slong_p - Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
  • mpf_fits_uint_p - Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
  • mpf_fits_sint_p - Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
  • mpf_fits_sshort_p - Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
  • mpf_fits_ushort_p - Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
  • mpf_urandomb - Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.
  • mpf_random2 - Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Low-level Functions:

  • mpn_add_n - Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.
  • mpn_add_1 - Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.
  • mpn_add - Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.
  • mpn_sub_n - Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.
  • mpn_sub_1 - Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.
  • mpn_sub - Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.
  • mpn_neg - Perform the negation of {sp, n}, and write the result to {rp, n}.
  • mpn_mul_n - Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.
  • mpn_mul - Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.
  • mpn_sqr - Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.
  • mpn_mul_1 - Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.
  • mpn_addmul_1 - Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.
  • mpn_submul_1 - Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.
  • mpn_tdiv_qr - Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.
  • mpn_divrem_1 - Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
  • mpn_divmod_1 - Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
  • mpn_divexact_1 - Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.
  • mpn_divexact_by3 - Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
  • mpn_divexact_by3c - Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
  • mpn_mod_1 - Divide {s1p, s1n} by s2limb, and return the remainder.
  • mpn_lshift - Shift {sp, n} left by count bits, and write the result to {rp, n}.
  • mpn_rshift - Shift {sp, n} right by count bits, and write the result to {rp, n}.
  • mpn_cmp - Compare {s1p, n} and {s2p, n}.
  • mpn_zero_p - Test {sp, n} and return 1 if the operand is zero, 0 otherwise.
  • mpn_gcd - Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
  • mpn_gcd_1 - Return the greatest common divisor of {xp, xn} and ylimb.
  • mpn_gcdext - Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
  • mpn_sqrtrem - Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.
  • mpn_sizeinbase - Return the size of {xp, n} measured in number of digits in the given base.
  • mpn_get_str - Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.
  • mpn_set_str - Convert bytes {str, strsize} in the given base to limbs at rp.
  • mpn_scan0 - Scan s1p from bit position bit for the next clear bit.
  • mpn_scan1 - Scan s1p from bit position bit for the next set bit.
  • mpn_random - Generate a random number of length r1n and store it at r1p.
  • mpn_random2 - Generate a random number of length r1n and store it at r1p.
  • mpn_popcount - Count the number of set bits in {s1p, n}.
  • mpn_hamdist - Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.
  • mpn_perfect_square_p - Return non-zero iff {s1p, n} is a perfect square.
  • mpn_perfect_power_p - Return non-zero iff {sp, n} is a perfect power.
  • mpn_and_n - Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_ior_n - Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_xor_n - Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_andn_n - Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
  • mpn_iorn_n - Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
  • mpn_nand_n - Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_nior_n - Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_xnor_n - Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_com - Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.
  • mpn_copyi - Copy from {s1p, n} to {rp, n}, increasingly.
  • mpn_copyd - Copy from {s1p, n} to {rp, n}, decreasingly.
  • mpn_zero - Zero {rp, n}.

Low-level functions for cryptography:

  • mpn_cnd_add_n - If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
  • mpn_cnd_sub_n - If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
  • mpn_sec_add_1 - Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
  • mpn_sec_add_1_itch - Return the scratch space in number of limbs required by the function mpn_sec_add_1.
  • mpn_sec_sub_1 - Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
  • mpn_sec_sub_1_itch - Return the scratch space in number of limbs required by the function mpn_sec_sub_1.
  • mpn_cnd_swap - If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
  • mpn_sec_mul - Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.
  • mpn_sec_mul_itch - Return the scratch space in number of limbs required by the function mpn_sec_mul.
  • mpn_sec_sqr - Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.
  • mpn_sec_sqr_itch - Return the scratch space in number of limbs required by the function mpn_sec_sqr.
  • mpn_sec_powm - Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.
  • mpn_sec_powm_itch - Return the scratch space in number of limbs required by the function mpn_sec_powm.
  • mpn_sec_tabselect - Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.
  • mpn_sec_div_qr - Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.
  • mpn_sec_div_qr_itch - Return the scratch space in number of limbs required by the function mpn_sec_div_qr.
  • mpn_sec_div_r - Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
  • mpn_sec_div_r_itch - Return the scratch space in number of limbs required by the function mpn_sec_div_r.
  • mpn_sec_invert - Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.
  • mpn_sec_invert_itch - Return the scratch space in number of limbs required by the function mpn_sec_invert.

Random Number Functions:

Random State Initialization:

  • gmp_randinit_default - Initialize state with a default algorithm.
  • gmp_randinit_mt - Initialize state for a Mersenne Twister algorithm.
  • gmp_randinit_lc_2exp - Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.
  • gmp_randinit_lc_2exp_size - Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp.
  • gmp_randinit_set - Initialize rop with a copy of the algorithm and state from op.
  • gmp_randclear - Free all memory occupied by state.

Random State Seeding:

  • gmp_randseed - Set an initial seed value into state.
  • gmp_randseed_ui - Set an initial seed value into state.

Random State Miscellaneous:

  • gmp_urandomb_ui - Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.
  • gmp_urandomm_ui - Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.

Formatted Output:

Formatted Output Functions:

  • gmp_printf - Print to the standard output stdout.
  • gmp_vprintf - Print to the standard output stdout.
  • gmp_fprintf - Print to the stream fp.
  • gmp_vfprintf - Print to the stream fp.
  • gmp_sprintf - Form a null-terminated string in buf.
  • gmp_vsprintf - Form a null-terminated string in buf.
  • gmp_snprintf - Form a null-terminated string in buf.
  • gmp_vsnprintf - Form a null-terminated string in buf.
  • gmp_asprintf - Form a null-terminated string in a block of memory obtained from the current memory allocation function.
  • gmp_vasprintf - Form a null-terminated string in a block of memory obtained from the current memory allocation function.

Formatted Input:

Formatted Input Functions:

  • gmp_scanf - Read from the standard input stdin.
  • gmp_vscanf - Read from the standard input stdin.
  • gmp_fscanf - Read from the stream fp.
  • gmp_vfscanf - Read from the stream fp.
  • gmp_sscanf - Read from a null-terminated string s.
  • gmp_vsscanf - Read from a null-terminated string s.

Custom Allocation:

  • mp_set_memory_functions - Replace the current allocation functions from the arguments.
  • mp_get_memory_functions - Get the current allocation functions, storing function pointers to the locations given by the arguments.
  • allocate - Return a pointer to newly allocated space with at least alloc_size bytes.
  • reallocate - Resize a previously allocated block ptr of old_size bytes to be new_size bytes.
  • free - De-allocate the space pointed to by ptrs.
  • ZeroMemory - The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
See Also

Reference

Math.Gmp.Native Namespace


gmp_lib Properties

gmp_lib Properties

The gmp_lib type exposes the following members.

Properties
Name | Description
gmp_errno | Gets or sets the global GMP error number.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.gmp_errno Property

gmp_libgmp_errno Property
Gets or sets the global GMP error number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_errno { get; set; }
Public Shared Property gmp_errno As Integer
    Get
    Set
public:
static property int gmp_errno {
    int get ();
    void set (int value);
}
static member gmp_errno : int with get, set

Property Value

Type: Int32
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib Methods

gmp_lib Methods

The gmp_lib type exposes the following members.

Methods
Name | Description
_mpz_realloc | Change the space for integer to new_alloc limbs.
allocate | Return a pointer to newly allocated space with at least alloc_size bytes.
free(IntPtr) | Free the unmanaged memory at ptr.
free(char_ptr) | De-allocate the space pointed to by ptr.
free(gmp_randstate_t) | De-allocate the space pointed to by ptr.
free(mp_ptr) | De-allocate the space pointed to by ptrs.
free(void_ptr) | De-allocate the space pointed to by ptr.
free(void_ptr, size_t) | De-allocate the space pointed to by ptr.
gmp_asprintf | Form a null-terminated string in a block of memory obtained from the current memory allocation function.
gmp_fprintf | Print to the stream fp.
gmp_fscanf | Read from the stream fp.
gmp_printf | Print to the standard output stdout.
gmp_randclear | Free all memory occupied by state.
gmp_randinit_default | Initialize state with a default algorithm.
gmp_randinit_lc_2exp | Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.
gmp_randinit_lc_2exp_size | Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp.
gmp_randinit_mt | Initialize state for a Mersenne Twister algorithm.
gmp_randinit_set | Initialize rop with a copy of the algorithm and state from op.
gmp_randseed | Set an initial seed value into state.
gmp_randseed_ui | Set an initial seed value into state.
gmp_scanf | Read from the standard input stdin.
gmp_snprintf | Form a null-terminated string in buf.
gmp_sprintf | Form a null-terminated string in buf.
gmp_sscanf | Read from a null-terminated string s.
gmp_urandomb_ui | Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.
gmp_urandomm_ui | Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.
gmp_vasprintf | Form a null-terminated string in a block of memory obtained from the current memory allocation function.
gmp_vfprintf | Print to the stream fp.
gmp_vfscanf | Read from the stream fp.
gmp_vprintf | Print to the standard output stdout.
gmp_vscanf | Read from the standard input stdin.
gmp_vsnprintf | Form a null-terminated string in buf.
gmp_vsprintf | Form a null-terminated string in buf.
gmp_vsscanf | Read from a null-terminated string s.
mp_get_memory_functions | Get the current allocation functions, storing function pointers to the locations given by the arguments.
mp_set_memory_functions | Replace the current allocation functions from the arguments.
mpf_abs | Set rop to | op |.
mpf_add | Set rop to op1 + op2.
mpf_add_ui | Set rop to op1 + op2.
mpf_ceil | Set rop to op rounded to the next higher integer.
mpf_clear | Free the space occupied by x.
mpf_clears | Free the space occupied by a NULL-terminated list of mpf_t variables.
mpf_cmp | Compare op1 and op2.
mpf_cmp_d | Compare op1 and op2.
mpf_cmp_si | Compare op1 and op2.
mpf_cmp_ui | Compare op1 and op2.
mpf_cmp_z | Compare op1 and op2.
mpf_div | Set rop to op1 / op2.
mpf_div_2exp | Set rop to op1 / 2^op2.
mpf_div_ui | Set rop to op1 / op2.
mpf_fits_sint_p | Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
mpf_fits_slong_p | Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
mpf_fits_sshort_p | Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
mpf_fits_uint_p | Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
mpf_fits_ulong_p | Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
mpf_fits_ushort_p | Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
mpf_floor | Set rop to op rounded to the next lower integer.
mpf_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpf_get_d_2exp | Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.
mpf_get_default_prec | Return the default precision actually used.
mpf_get_prec | Return the current precision of op, in bits.
mpf_get_si | Convert op to a 32-bit integer, truncating any fraction part.
mpf_get_str(char_ptr, mp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
mpf_get_str(char_ptr, ptrmp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
mpf_get_ui | Convert op to an unsigned 32-bit integer, truncating any fraction part.
mpf_init | Initialize x to 0.
mpf_init_set | Initialize rop and set its value from op.
mpf_init_set_d | Initialize rop and set its value from op.
mpf_init_set_si | Initialize rop and set its value from op.
mpf_init_set_str | Initialize rop and set its value from the string in str.
mpf_init_set_ui | Initialize rop and set its value from op.
mpf_init2 | Initialize x to 0 and set its precision to be at least prec bits.
mpf_inits | Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.
mpf_inp_str | Read a string in base base from stream, and put the read float in rop.
mpf_integer_p | Return non-zero if op is an integer.
mpf_mul | Set rop to op1 * op2.
mpf_mul_2exp | Set rop to op1 * 2^op2.
mpf_mul_ui | Set rop to op1 * op2.
mpf_neg | Set rop to -op.
mpf_out_str | Print op to stream, as a string of digits.
mpf_pow_ui | Set rop to op1^op2.
mpf_random2 | Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.
mpf_reldiff | Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.
mpf_set | Set the value of rop from op.
mpf_set_d | Set the value of rop from op.
mpf_set_default_prec | Set the default precision to be at least prec bits.
mpf_set_prec | Set the precision of rop to be at least prec bits.
mpf_set_prec_raw | Set the precision of rop to be at least prec bits, without changing the memory allocated.
mpf_set_q | Set the value of rop from op.
mpf_set_si | Set the value of rop from op.
mpf_set_str | Set the value of rop from the string in str.
mpf_set_ui | Set the value of rop from op.
mpf_set_z | Set the value of rop from op.
mpf_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpf_size | Return the number of limbs currently in use.
mpf_sqrt | Set rop to the square root of op.
mpf_sqrt_ui | Set rop to the square root of op.
mpf_sub | Set rop to op1 - op2.
mpf_sub_ui | Set rop to op1 - op2.
mpf_swap | Swap rop1 and rop2 efficiently.
mpf_trunc | Set rop to op rounded to the integer towards zero.
mpf_ui_div | Set rop to op1 / op2.
mpf_ui_sub | Set rop to op1 - op2.
mpf_urandomb | Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.
mpn_add | Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.
mpn_add_1 | Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.
mpn_add_n | Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.
mpn_addmul_1 | Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.
mpn_and_n | Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_andn_n | Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
mpn_cmp | Compare {s1p, n} and {s2p, n}.
mpn_cnd_add_n | If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
mpn_cnd_sub_n | If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
mpn_cnd_swap | If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
mpn_com | Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.
mpn_copyd | Copy from {s1p, n} to {rp, n}, decreasingly.
mpn_copyi | Copy from {s1p, n} to {rp, n}, increasingly.
mpn_divexact_1 | Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.
mpn_divexact_by3 | Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
mpn_divexact_by3c | Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
mpn_divmod_1 | Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
mpn_divrem_1 | Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
mpn_gcd | Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
mpn_gcd_1 | Return the greatest common divisor of {xp, xn} and ylimb.
mpn_gcdext(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
mpn_gcdext(mp_ptr, mp_ptr, ptrmp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
mpn_get_str | Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.
mpn_hamdist | Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.
mpn_ior_n | Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_iorn_n | Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
mpn_lshift | Shift {sp, n} left by count bits, and write the result to {rp, n}.
mpn_mod_1 | Divide {s1p, s1n} by s2limb, and return the remainder.
mpn_mul | Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.
mpn_mul_1 | Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.
mpn_mul_n | Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.
mpn_nand_n | Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_neg | Perform the negation of {sp, n}, and write the result to {rp, n}.
mpn_nior_n | Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_perfect_power_p | Return non-zero iff {sp, n} is a perfect power.
mpn_perfect_square_p | Return non-zero iff {s1p, n} is a perfect square.
mpn_popcount | Count the number of set bits in {s1p, n}.
mpn_random | Generate a random number of length r1n and store it at r1p.
mpn_random2 | Generate a random number of length r1n and store it at r1p.
mpn_rshift | Shift {sp, n} right by count bits, and write the result to {rp, n}.
mpn_scan0 | Scan s1p from bit position bit for the next clear bit.
mpn_scan1 | Scan s1p from bit position bit for the next set bit.
mpn_sec_add_1 | Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
mpn_sec_add_1_itch | Return the scratch space in number of limbs required by the function mpn_sec_add_1.
mpn_sec_div_qr | Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.
mpn_sec_div_qr_itch | Return the scratch space in number of limbs required by the function mpn_sec_div_qr.
mpn_sec_div_r | Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
mpn_sec_div_r_itch | Return the scratch space in number of limbs required by the function mpn_sec_div_r.
mpn_sec_invert | Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.
mpn_sec_invert_itch | Return the scratch space in number of limbs required by the function mpn_sec_invert.
mpn_sec_mul | Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.
mpn_sec_mul_itch | Return the scratch space in number of limbs required by the function mpn_sec_mul.
mpn_sec_powm | Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.
mpn_sec_powm_itch | Return the scratch space in number of limbs required by the function mpn_sec_powm.
mpn_sec_sqr | Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.
mpn_sec_sqr_itch | Return the scratch space in number of limbs required by the function mpn_sec_sqr.
mpn_sec_sub_1 | Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
mpn_sec_sub_1_itch | Return the scratch space in number of limbs required by the function mpn_sec_sub_1.
mpn_sec_tabselect | Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.
mpn_set_str | Convert bytes {str, strsize} in the given base to limbs at rp.
mpn_sizeinbase | Return the size of {xp, n} measured in number of digits in the given base.
mpn_sqr | Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.
mpn_sqrtrem | Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.
mpn_sub | Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.
mpn_sub_1 | Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.
mpn_sub_n | Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.
mpn_submul_1 | Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.
mpn_tdiv_qr | Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.
mpn_xnor_n | Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
mpn_xor_n | Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
mpn_zero | Zero {rp, n}.
mpn_zero_p | Test {sp, n} and return 1 if the operand is zero, 0 otherwise.
mpq_abs | Set rop to the absolute value of op.
mpq_add | Set sum to addend1 + addend2.
mpq_canonicalize | Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.
mpq_clear | Free the space occupied by x.
mpq_clears | Free the space occupied by a NULL-terminated list of mpq_t variables.
mpq_cmp | Compare op1 and op2.
mpq_cmp_si | Compare op1 and num2 / den2.
mpq_cmp_ui | Compare op1 and num2 / den2.
mpq_cmp_z | Compare op1 and op2.
mpq_denref | Return a reference to the denominator op.
mpq_div | Set quotient to dividend / divisor.
mpq_div_2exp | Set rop to op1 / 2^op2.
mpq_equal | Return non-zero if op1 and op2 are equal, zero if they are non-equal.
mpq_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpq_get_den | Set denominator to the denominator of rational.
mpq_get_num | Set numerator to the numerator of rational.
mpq_get_str | Convert op to a string of digits in base base.
mpq_init | Initialize x and set it to 0/1.
mpq_inits | Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.
mpq_inp_str | Read a string of digits from stream and convert them to a rational in rop.
mpq_inv | Set inverted_number to 1 / number.
mpq_mul | Set product to multiplier * multiplicand.
mpq_mul_2exp | Set rop to op1 * 2*op2.
mpq_neg | Set negated_operand to -operand.
mpq_numref | Return a reference to the numerator op.
mpq_out_str | Output op on stdio stream stream, as a string of digits in base base.
mpq_set | Assign rop from op.
mpq_set_d | Set rop to the value of op. There is no rounding, this conversion is exact.
mpq_set_den | Set the denominator of rational to denominator.
mpq_set_f | Set rop to the value of op. There is no rounding, this conversion is exact.
mpq_set_num | Set the numerator of rational to numerator.
mpq_set_si | Set the value of rop to op1 / op2.
mpq_set_str | Set rop from a null-terminated string str in the given base.
mpq_set_ui | Set the value of rop to op1 / op2.
mpq_set_z | Assign rop from op.
mpq_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpq_sub | Set difference to minuend - subtrahend.
mpq_swap | Swap the values rop1 and rop2 efficiently.
mpz_2fac_ui | Set rop to the double-factorial n!!.
mpz_abs | Set rop to the absolute value of op.
mpz_add | Set rop to op1 + op2.
mpz_add_ui | Set rop to op1 + op2.
mpz_addmul | Set rop to rop + op1 * op2.
mpz_addmul_ui | Set rop to rop + op1 * op2.
mpz_and | Set rop to op1 bitwise-and op2.
mpz_bin_ui | Compute the binomial coefficient n over k and store the result in rop.
mpz_bin_uiui | Compute the binomial coefficient n over k and store the result in rop.
mpz_cdiv_q | Set the quotient q to ceiling(n / d).
mpz_cdiv_q_2exp | Set the quotient q to ceiling(n / 2^b).
mpz_cdiv_q_ui | Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.
mpz_cdiv_qr | Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.
mpz_cdiv_qr_ui | Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.
mpz_cdiv_r | Set the remainder r to n - q * d where q = ceiling(n / d).
mpz_cdiv_r_2exp | Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).
mpz_cdiv_r_ui | Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.
mpz_cdiv_ui | Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).
mpz_clear | Free the space occupied by x.
mpz_clears | Free the space occupied by a NULL-terminated list of mpz_t variables.
mpz_clrbit | Clear bit bit_index in rop.
mpz_cmp | Compare op1 and op2.
mpz_cmp_d | Compare op1 and op2.
mpz_cmp_si | Compare op1 and op2.
mpz_cmp_ui | Compare op1 and op2.
mpz_cmpabs | Compare the absolute values of op1 and op2.
mpz_cmpabs_d | Compare the absolute values of op1 and op2.
mpz_cmpabs_ui | Compare the absolute values of op1 and op2.
mpz_com | Set rop to the one’s complement of op.
mpz_combit | Complement bit bit_index in rop.
mpz_congruent_2exp_p | Return non-zero if n is congruent to c modulo 2^b.
mpz_congruent_p | Return non-zero if n is congruent to c modulo d.
mpz_congruent_ui_p | Return non-zero if n is congruent to c modulo d.
mpz_divexact | Set q to n / d when it is known in advance that d divides n.
mpz_divexact_ui | Set q to n / d when it is known in advance that d divides n.
mpz_divisible_2exp_p | Return non-zero if n is exactly divisible by 2^b.
mpz_divisible_p | Return non-zero if n is exactly divisible by d.
mpz_divisible_ui_p | Return non-zero if n is exactly divisible by d.
mpz_even_p | Determine whether op is even.
mpz_export(void_ptr, ptrsize_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
mpz_export(void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
mpz_fac_ui | Set rop to the factorial n!.
mpz_fdiv_q | Set the quotient q to floor(n / d).
mpz_fdiv_q_2exp | Set the quotient q to floor(n / 2^b).
mpz_fdiv_q_ui | Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.
mpz_fdiv_qr | Set the quotient q to floor(n / d), and set the remainder r to n - q * d.
mpz_fdiv_qr_ui | Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.
mpz_fdiv_r | Set the remainder r to n - q * d where q = floor(n / d).
mpz_fdiv_r_2exp | Set the remainder r to n - q * 2^b where q = floor(n / 2^b).
mpz_fdiv_r_ui | Set the remainder r to n - q * d where q = floor(n / d), and return | r |.
mpz_fdiv_ui | Return the remainder | r | where r = n - q * d, and where q = floor(n / d).
mpz_fib_ui | Sets fn to to F[n], the n’th Fibonacci number.
mpz_fib2_ui | Sets fn to F[n], and fnsub1 to F[n - 1].
mpz_fits_sint_p | Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
mpz_fits_slong_p | Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
mpz_fits_sshort_p | Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
mpz_fits_uint_p | Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
mpz_fits_ulong_p | Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
mpz_fits_ushort_p | Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
mpz_gcd | Set rop to the greatest common divisor of op1 and op2.
mpz_gcd_ui | Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.
mpz_gcdext | Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.
mpz_get_d | Convert op to a double, truncating if necessary (i.e. rounding towards zero).
mpz_get_d_2exp | Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
mpz_get_si | Return the value of op as an signed long.
mpz_get_str | Convert op to a string of digits in base base.
mpz_get_ui | Return the value of op as an unsigned long.
mpz_getlimbn | Return limb number n from op.
mpz_hamdist | Return the hamming distance between the two operands.
mpz_import | Set rop from an array of word data at op.
mpz_init | Initialize x, and set its value to 0.
mpz_init_set | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_d | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_si | Initialize rop with limb space and set the initial numeric value from op.
mpz_init_set_str | Initialize rop and set its value like mpz_set_str.
mpz_init_set_ui | Initialize rop with limb space and set the initial numeric value from op.
mpz_init2 | Initialize x, with space for n-bit numbers, and set its value to 0.
mpz_inits | Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.
mpz_inp_raw | Input from stdio stream stream in the format written by mpz_out_raw, and put the result in rop.
mpz_inp_str | Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.
mpz_invert | Compute the inverse of op1 modulo op2 and put the result in rop.
mpz_ior | Set rop to op1 bitwise inclusive-or op2.
mpz_jacobi | Calculate the Jacobi symbol (a/b).
mpz_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_kronecker_si | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_kronecker_ui | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_lcm | Set rop to the least common multiple of op1 and op2.
mpz_lcm_ui | Set rop to the least common multiple of op1 and op2.
mpz_legendre | Calculate the Legendre symbol (a/p).
mpz_limbs_finish | Updates the internal size field of x.
mpz_limbs_modify | Return a pointer to the limb array of x, intended for write access.
mpz_limbs_read | Return a pointer to the limb array representing the absolute value of x.
mpz_limbs_write | Return a pointer to the limb array of x, intended for write access.
mpz_lucnum_ui | Sets ln to to L[n], the n’th Lucas number.
mpz_lucnum2_ui | Sets ln to L[n], and lnsub1 to L[n - 1].
mpz_mfac_uiui | Set rop to the m-multi-factorial n!^(m)n.
mpz_millerrabin | An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.
mpz_mod | Set r to n mod d.
mpz_mod_ui | Set r to n mod d.
mpz_mul | Set rop to op1 * op2.
mpz_mul_2exp | Set rop to op1 * 2^op2.
mpz_mul_si | Set rop to op1 * op2.
mpz_mul_ui | Set rop to op1 * op2.
mpz_neg | Set rop to -op.
mpz_nextprime | Set rop to the next prime greater than op.
mpz_odd_p | Determine whether op is odd.
mpz_out_raw | Output op on stdio stream stream, in raw binary format.
mpz_out_str | Output op on stdio stream stream, as a string of digits in base base.
mpz_perfect_power_p | Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
mpz_perfect_square_p | Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.
mpz_popcount | Return the population count of op.
mpz_pow_ui | Set rop to base^exp. The case 0^0 yields 1.
mpz_powm | Set rop to (base^exp) modulo mod.
mpz_powm_sec | Set rop to (base^exp) modulo mod.
mpz_powm_ui | Set rop to (base^exp) modulo mod.
mpz_primorial_ui | Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.
mpz_probab_prime_p | Determine whether n is prime.
mpz_random | Generate a random integer of at most max_size limbs.
mpz_random2 | Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.
mpz_realloc2 | Change the space allocated for x to n bits.
mpz_remove | Remove all occurrences of the factor f from op and store the result in rop.
mpz_roinit_n | Special initialization of x, using the given limb array and size.
mpz_root | Set rop to the truncated integer part of the nth root of op.
mpz_rootrem | Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.
mpz_rrandomb | Generate a random integer with long strings of zeros and ones in the binary representation.
mpz_scan0 | Scan op for 0 bit.
mpz_scan1 | Scan op for 1 bit.
mpz_set | Set the value of rop from op.
mpz_set_d | Set the value of rop from op.
mpz_set_f | Set the value of rop from op.
mpz_set_q | Set the value of rop from op.
mpz_set_si | Set the value of rop from op.
mpz_set_str | Set the value of rop from str, a null-terminated C string in base base.
mpz_set_ui | Set the value of rop from op.
mpz_setbit | Set bit bit_index in rop.
mpz_sgn | Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
mpz_si_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_size | Return the size of op measured in number of limbs.
mpz_sizeinbase | Return the size of op measured in number of digits in the given base.
mpz_sqrt | Set rop to the truncated integer part of the square root of op.
mpz_sqrtrem | Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.
mpz_sub | Set rop to op1 - op2.
mpz_sub_ui | Set rop to op1 - op2.
mpz_submul | Set rop to rop - op1 * op2.
mpz_submul_ui | Set rop to rop - op1 * op2.
mpz_swap | Swap the values rop1 and rop2 efficiently.
mpz_tdiv_q | Set the quotient q to trunc(n / d).
mpz_tdiv_q_2exp | Set the quotient q to trunc(n / 2^b).
mpz_tdiv_q_ui | Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.
mpz_tdiv_qr | Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.
mpz_tdiv_qr_ui | Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.
mpz_tdiv_r | Set the remainder r to n - q * d where q = trunc(n / d).
mpz_tdiv_r_2exp | Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).
mpz_tdiv_r_ui | Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.
mpz_tdiv_ui | Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).
mpz_tstbit | Test bit bit_index in op and return 0 or 1 accordingly.
mpz_ui_kronecker | Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
mpz_ui_pow_ui | Set rop to base^exp. The case 0^0 yields 1.
mpz_ui_sub | Set rop to op1 - op2.
mpz_urandomb | Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.
mpz_urandomm | Generate a uniform random integer in the range 0 to n - 1, inclusive.
mpz_xor | Set rop to op1 bitwise exclusive-or op2.
reallocate | Resize a previously allocated block ptr of old_size bytes to be new_size bytes.
ZeroMemory | The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib._mpz_realloc Method

gmp_lib_mpz_realloc Method
Change the space for integer to new_alloc limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void _mpz_realloc(
    mpz_t integer,
    mp_size_t new_alloc
)
Public Shared Sub _mpz_realloc (
    integer As mpz_t,
    new_alloc As mp_size_t
)
public:
static void _mpz_realloc(
    mpz_t^ integer,
    mp_size_t new_alloc
)
static member _mpz_realloc :
        integer : mpz_t *
        new_alloc : mp_size_t -> unit

Parameters

integer
Type: Math.Gmp.Nativempz_t
The integer to resize.
new_alloc
Type: Math.Gmp.Nativemp_size_t
The new number of limbs.
Remarks

The value in integer is preserved if it fits, or is set to 0 if not.

mpz_realloc2 is the preferred way to accomplish allocation changes like this. mpz_realloc2 and _mpz_realloc are the same except that _mpz_realloc takes its size in limbs.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x to a 77-bit integer.
char_ptr value = new char_ptr("1000 0000 0000 0000 0000");
gmp_lib.mpz_set_str(x, value, 16);

// Resize x to 50 limbs, and assert that its value has not changed.
gmp_lib._mpz_realloc(x, 50);
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x);
Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", ""));

// Resize x to 1 limb, and assert that its value has changed to 0.
gmp_lib._mpz_realloc(x, 1);
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
' Create and initialize new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x to a 77-bit integer.
Dim value As New char_ptr("1000 0000 0000 0000 0000")
gmp_lib.mpz_set_str(x, value, 16)

' Resize x to 50 limbs, and assert that its value has not changed.
gmp_lib._mpz_realloc(x, 50)
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x)
Assert.IsTrue(s.ToString() = "1000 0000 0000 0000 0000".Replace(" ", ""))

' Resize x to 1 limb, and assert that its value has changed to 0.
gmp_lib._mpz_realloc(x, 1)
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0)

' Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_realloc2
mpz_getlimbn
mpz_size
mpz_limbs_read
mpz_limbs_write
mpz_limbs_modify
mpz_limbs_finish
mpz_roinit_n


gmp_lib.allocate Method

gmp_liballocate Method
Return a pointer to newly allocated space with at least alloc_size bytes.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void_ptr allocate(
    size_t alloc_size
)
Public Shared Function allocate (
    alloc_size As size_t
) As void_ptr
public:
static void_ptr allocate(
    size_t alloc_size
)
static member allocate :
        alloc_size : size_t -> void_ptr

Parameters

alloc_size
Type: Math.Gmp.Nativesize_t
The minimum number of bytes to allocate.

Return Value

Type: void_ptr
A pointer to newly allocated space with at least alloc_size bytes.
Remarks
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
free
reallocate


gmp_lib.free Method

gmp_libfree Method
Overload List
Name | Description
free(IntPtr) | Free the unmanaged memory at ptr.
free(char_ptr) | De-allocate the space pointed to by ptr.
free(gmp_randstate_t) | De-allocate the space pointed to by ptr.
free(mp_ptr) | De-allocate the space pointed to by ptrs.
free(void_ptr) | De-allocate the space pointed to by ptr.
free(void_ptr, size_t) | De-allocate the space pointed to by ptr.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.free Method (IntPtr)

gmp_libfree Method (IntPtr)
Free the unmanaged memory at ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    IntPtr ptr
)
Public Shared Sub free (
    ptr As IntPtr
)
public:
static void free(
    IntPtr ptr
)
static member free :
        ptr : IntPtr -> unit

Parameters

ptr
Type: SystemIntPtr
Pointer to unmanaged memory.
See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace


gmp_lib.free Method (char_ptr)

gmp_libfree Method (char_ptr)
De-allocate the space pointed to by ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    char_ptr ptr
)
Public Shared Sub free (
    ptr As char_ptr
)
public:
static void free(
    char_ptr ptr
)
static member free :
        ptr : char_ptr -> unit

Parameters

ptr
Type: Math.Gmp.Nativechar_ptr
Pointer to previously allocated memory.
Remarks
See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace
gmp_libfree(void_ptr, size_t)


gmp_lib.free Method (gmp_randstate_t)

gmp_libfree Method (gmp_randstate_t)
De-allocate the space pointed to by ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    gmp_randstate_t ptr
)
Public Shared Sub free (
    ptr As gmp_randstate_t
)
public:
static void free(
    gmp_randstate_t^ ptr
)
static member free :
        ptr : gmp_randstate_t -> unit

Parameters

ptr
Type: Math.Gmp.Nativegmp_randstate_t
Pointer to previously allocated memory.
Remarks
See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace
gmp_libfree(void_ptr, size_t)


gmp_lib.free Method (mp_ptr[])

gmp_libfree Method (mp_ptr)
De-allocate the space pointed to by ptrs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    params mp_ptr[] ptrs
)
Public Shared Sub free (
    ParamArray ptrs As mp_ptr()
)
public:
static void free(
    ... array<mp_ptr^>^ ptrs
)
static member free :
        ptrs : mp_ptr[] -> unit

Parameters

ptrs
Type: Math.Gmp.Nativemp_ptr
Pointers to previously allocated memory.
Remarks
See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace
gmp_libfree(void_ptr, size_t)


gmp_lib.free Method (void_ptr)

gmp_libfree Method (void_ptr)
De-allocate the space pointed to by ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    void_ptr ptr
)
Public Shared Sub free (
    ptr As void_ptr
)
public:
static void free(
    void_ptr ptr
)
static member free :
        ptr : void_ptr -> unit

Parameters

ptr
Type: Math.Gmp.Nativevoid_ptr
Pointer to previously allocated memory.
Remarks
See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace
gmp_libfree(void_ptr, size_t)


gmp_lib.free Method (void_ptr, size_t)

gmp_libfree Method (void_ptr, size_t)
De-allocate the space pointed to by ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void free(
    void_ptr ptr,
    size_t size
)
Public Shared Sub free (
    ptr As void_ptr,
    size As size_t
)
public:
static void free(
    void_ptr ptr,
    size_t size
)
static member free :
        ptr : void_ptr *
        size : size_t -> unit

Parameters

ptr
Type: Math.Gmp.Nativevoid_ptr
Pointer to previously allocated block.
size
Type: Math.Gmp.Nativesize_t
Number of bytes of previously allocated block.
Remarks

The free function parameter size is passed for convenience, but of course it can be ignored if not needed by an implementation. The default functions using malloc and friends for instance don’t use it.

See Also

Reference

gmp_lib Class
free Overload
Math.Gmp.Native Namespace
allocate
reallocate


gmp_lib.gmp_asprintf Method

gmp_libgmp_asprintf Method
Form a null-terminated string in a block of memory obtained from the current memory allocation function.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_asprintf(
    ptr<char_ptr> pp,
    string fmt,
    params Object[] args
)
Public Shared Function gmp_asprintf (
    pp As ptr(Of char_ptr),
    fmt As String,
    ParamArray args As Object()
) As Integer
public:
static int gmp_asprintf(
    ptr<char_ptr>^ pp,
    String^ fmt,
    ... array<Object^>^ args
)
static member gmp_asprintf :
        pp : ptr<char_ptr> *
        fmt : string *
        args : Object[] -> int

Parameters

pp
Type: Math.Gmp.Nativeptr char_ptr
Pointer to returned, allocated string.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value is the number of characters produced, excluding the null-terminator.
Remarks

The block will be the size of the string and null-terminator. The address of the block in stored to pp.

Unlike the C library asprintf, gmp_asprintf doesn’t return -1 if there’s no more memory available, it lets the current allocation function handle that.

Examples
C#
VB
C++
F#
Copy
// Create pointer to unmanaged character string pointer.
ptr<char_ptr> str = new ptr<char_ptr>();

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to newly allocated unmanaged memory string.
Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str.Value);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Create pointer to unmanaged character string pointer.
Dim str As New ptr(Of char_ptr)()

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to newly allocated unmanaged memory string.
Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.Value.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str.Value)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_snprintf
gmp_sprintf
gmp_vasprintf


gmp_lib.gmp_fprintf Method

gmp_libgmp_fprintf Method
Print to the stream fp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_fprintf(
    ptr<FILE> fp,
    string fmt,
    params Object[] args
)
Public Shared Function gmp_fprintf (
    fp As ptr(Of FILE),
    fmt As String,
    ParamArray args As Object()
) As Integer
public:
static int gmp_fprintf(
    ptr<FILE>^ fp,
    String^ fmt,
    ... array<Object^>^ args
)
static member gmp_fprintf :
        fp : ptr<FILE> *
        fmt : string *
        args : Object[] -> int

Parameters

fp
Type: Math.Gmp.Nativeptr FILE
File stream.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, or -1 if an error occurred.
Examples
C#
VB
C++
F#
Copy
// Create unique file pathname and a file pointer.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Open file stream and print to it.
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
fclose(stream.Value.Value);
Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
' Create unique file pathname and a file pointer.
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Open file stream and print to it.
_wfopen_s(stream.Value.Value, pathname, "w")
Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
fclose(stream.Value.Value)
Assert.IsTrue(System.IO.File.ReadAllText(pathname) = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_printf
gmp_sprintf
gmp_vfprintf


gmp_lib.gmp_fscanf Method

gmp_libgmp_fscanf Method
Read from the stream fp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_fscanf(
    ptr<FILE> fp,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_fscanf (
    fp As ptr(Of FILE),
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_fscanf(
    ptr<FILE>^ fp,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_fscanf :
        fp : ptr<FILE> *
        fmt : string *
        ap : Object[] -> int

Parameters

fp
Type: Math.Gmp.Nativeptr FILE
File stream.
fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
// Create unique filename and stream pointer.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();

mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

// Write string to file, and then read values from it.
System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000");
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
fclose(stream.Value.Value);

// Assert values read.
Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Create unique filename and stream pointer.
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()

Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

' Write string to file, and then read values from it.
System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000")
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)
fclose(stream.Value.Value)

' Assert values read.
Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_scanf
gmp_sscanf
gmp_vfscanf


gmp_lib.gmp_printf Method

gmp_libgmp_printf Method
Print to the standard output stdout.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_printf(
    string fmt,
    params Object[] args
)
Public Shared Function gmp_printf (
    fmt As String,
    ParamArray args As Object()
) As Integer
public:
static int gmp_printf(
    String^ fmt,
    ... array<Object^>^ args
)
static member gmp_printf :
        fmt : string *
        args : Object[] -> int

Parameters

fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, or -1 if an error occurred.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to standard output.
Assert.IsTrue(gmp_lib.gmp_printf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);

// Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to standard output.
Assert.IsTrue(gmp_lib.gmp_printf("%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_fprintf
gmp_sprintf
gmp_vprintf


gmp_lib.gmp_randclear Method

gmp_libgmp_randclear Method
Free all memory occupied by state.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randclear(
    gmp_randstate_t state
)
Public Shared Sub gmp_randclear (
    state As gmp_randstate_t
)
public:
static void gmp_randclear(
    gmp_randstate_t^ state
)
static member gmp_randclear :
        state : gmp_randstate_t -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
A state.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randinit_default
gmp_randinit_lc_2exp
gmp_randinit_lc_2exp_size
gmp_randinit_mt
gmp_randinit_set


gmp_lib.gmp_randinit_default Method

gmp_libgmp_randinit_default Method
Initialize state with a default algorithm.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randinit_default(
    gmp_randstate_t state
)
Public Shared Sub gmp_randinit_default (
    state As gmp_randstate_t
)
public:
static void gmp_randinit_default(
    gmp_randstate_t^ state
)
static member gmp_randinit_default :
        state : gmp_randstate_t -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize.
Remarks

This will be a compromise between speed and randomness, and is recommended for applications with no special requirements. Currently this is gmp_randinit_mt.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state.
gmp_randstate_t state = new gmp_randstate_t();

// Initialize state with default random number generator algorithm.
gmp_lib.gmp_randinit_default(state);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create new random number generator state.
Dim state As New gmp_randstate_t()

' Initialize state with default random number generator algorithm.
gmp_lib.gmp_randinit_default(state)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randclear
gmp_randinit_lc_2exp
gmp_randinit_lc_2exp_size
gmp_randinit_mt
gmp_randinit_set


gmp_lib.gmp_randinit_lc_2exp Method

gmp_libgmp_randinit_lc_2exp Method
Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randinit_lc_2exp(
    gmp_randstate_t state,
    mpz_t a,
    uint c,
    mp_bitcnt_t m2exp
)
Public Shared Sub gmp_randinit_lc_2exp (
    state As gmp_randstate_t,
    a As mpz_t,
    c As UInteger,
    m2exp As mp_bitcnt_t
)
public:
static void gmp_randinit_lc_2exp(
    gmp_randstate_t^ state,
    mpz_t^ a,
    unsigned int c,
    mp_bitcnt_t m2exp
)
static member gmp_randinit_lc_2exp :
        state : gmp_randstate_t *
        a : mpz_t *
        c : uint32 *
        m2exp : mp_bitcnt_t -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize.
a
Type: Math.Gmp.Nativempz_t
Parameter of the algorithm.
c
Type: SystemUInt32
Parameter of the algorithm.
m2exp
Type: Math.Gmp.Nativemp_bitcnt_t
Parameter of the algorithm.
Remarks

The low bits of X in this algorithm are not very random. The least significant bit will have a period no more than 2, and the second bit no more than 4, etc. For this reason only the high half of each X is actually used.

When a random number of more than m2exp / 2 bits is to be generated, multiple iterations of the recurrence are used and the results concatenated.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state.
gmp_randstate_t state = new gmp_randstate_t();

// Initialize state with a linear congruential random number generator algorithm.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 100000U);
gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300);

// Free all memory occupied by state and a.
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clear(a);
' Create new random number generator state.
Dim state As New gmp_randstate_t()

' Initialize state with a linear congruential random number generator algorithm.
Dim a As New mpz_t()

gmp_lib.mpz_init_set_ui(a, 100000UI)
gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300)

' Free all memory occupied by state and a.
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clear(a)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randclear
gmp_randinit_default
gmp_randinit_lc_2exp_size
gmp_randinit_mt
gmp_randinit_set


gmp_lib.gmp_randinit_lc_2exp_size Method

gmp_libgmp_randinit_lc_2exp_size Method
Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_randinit_lc_2exp_size(
    gmp_randstate_t state,
    mp_bitcnt_t size
)
Public Shared Function gmp_randinit_lc_2exp_size (
    state As gmp_randstate_t,
    size As mp_bitcnt_t
) As Integer
public:
static int gmp_randinit_lc_2exp_size(
    gmp_randstate_t^ state,
    mp_bitcnt_t size
)
static member gmp_randinit_lc_2exp_size :
        state : gmp_randstate_t *
        size : mp_bitcnt_t -> int

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize.
size
Type: Math.Gmp.Nativemp_bitcnt_t

Return Value

Type: Int32
If successful the return value is non-zero. If size is bigger than the table data provides then the return value is zero.
Remarks

a, c and m2exp are selected from a table, chosen so that size bits (or more) of each X will be used, i.e. m2exp / 2 ≥ size.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state.
gmp_randstate_t state = new gmp_randstate_t();

// Initialize state with a linear congruential random number generator algorithm.
gmp_lib.gmp_randinit_lc_2exp_size(state, 30);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create new random number generator state.
Dim state As New gmp_randstate_t()

' Initialize state with a linear congruential random number generator algorithm.
gmp_lib.gmp_randinit_lc_2exp_size(state, 30)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randclear
gmp_randinit_default
gmp_randinit_lc_2exp
gmp_randinit_mt
gmp_randinit_set


gmp_lib.gmp_randinit_mt Method

gmp_libgmp_randinit_mt Method
Initialize state for a Mersenne Twister algorithm.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randinit_mt(
    gmp_randstate_t state
)
Public Shared Sub gmp_randinit_mt (
    state As gmp_randstate_t
)
public:
static void gmp_randinit_mt(
    gmp_randstate_t^ state
)
static member gmp_randinit_mt :
        state : gmp_randstate_t -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize.
Remarks

This algorithm is fast and has good randomness properties.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state.
gmp_randstate_t state = new gmp_randstate_t();

// Initialize state with Mersenne Twister random number generator algorithm.
gmp_lib.gmp_randinit_mt(state);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create new random number generator state.
Dim state As New gmp_randstate_t()

' Initialize state with Mersenne Twister random number generator algorithm.
gmp_lib.gmp_randinit_mt(state)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randclear
gmp_randinit_default
gmp_randinit_lc_2exp
gmp_randinit_lc_2exp_size
gmp_randinit_set


gmp_lib.gmp_randinit_set Method

gmp_libgmp_randinit_set Method
Initialize rop with a copy of the algorithm and state from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randinit_set(
    gmp_randstate_t rop,
    gmp_randstate_t op
)
Public Shared Sub gmp_randinit_set (
    rop As gmp_randstate_t,
    op As gmp_randstate_t
)
public:
static void gmp_randinit_set(
    gmp_randstate_t^ rop,
    gmp_randstate_t^ op
)
static member gmp_randinit_set :
        rop : gmp_randstate_t *
        op : gmp_randstate_t -> unit

Parameters

rop
Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize.
op
Type: Math.Gmp.Nativegmp_randstate_t
The source state.
Examples
C#
VB
C++
F#
Copy
// Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
gmp_randstate_t op = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(op);

// Create new random number generator state, and initialize it with the state op.
gmp_randstate_t rop = new gmp_randstate_t();
gmp_lib.gmp_randinit_set(rop, op);

// Free all memory occupied by op and rop.
gmp_lib.gmp_randclear(op);
gmp_lib.gmp_randclear(rop);
' Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
Dim op As New gmp_randstate_t()

gmp_lib.gmp_randinit_mt(op)

' Create new random number generator state, and initialize it with the state op.
Dim rop As New gmp_randstate_t()

gmp_lib.gmp_randinit_set(rop, op)

' Free all memory occupied by op and rop.
gmp_lib.gmp_randclear(op)
gmp_lib.gmp_randclear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randclear
gmp_randinit_default
gmp_randinit_lc_2exp
gmp_randinit_lc_2exp_size
gmp_randinit_mt


gmp_lib.gmp_randseed Method

gmp_libgmp_randseed Method
Set an initial seed value into state.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randseed(
    gmp_randstate_t state,
    mpz_t seed
)
Public Shared Sub gmp_randseed (
    state As gmp_randstate_t,
    seed As mpz_t
)
public:
static void gmp_randseed(
    gmp_randstate_t^ state,
    mpz_t^ seed
)
static member gmp_randseed :
        state : gmp_randstate_t *
        seed : mpz_t -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to seed.
seed
Type: Math.Gmp.Nativempz_t
The seed.
Remarks

The size of a seed determines how many different sequences of random numbers that it’s possible to generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed used, and this affects the randomness of separate number sequences. The method for choosing a seed is critical if the generated numbers are to be used for important applications, such as generating cryptographic keys.

Traditionally the system time has been used to seed, but care needs to be taken with this. If an application seeds often and the resolution of the system clock is low, then the same sequence of numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is required then it should definitely not be the only source for the seed value. On some systems there’s a special device /dev/random which provides random data better suited for use as a seed.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);

// Seed random number generator.
mpz_t seed = new mpz_t();
gmp_lib.mpz_init_set_ui(seed, 100000U);
gmp_lib.gmp_randseed(state, seed);

// Free all memory occupied by state and seed.
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clear(seed);
' Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
Dim state As New gmp_randstate_t()

gmp_lib.gmp_randinit_mt(state)

' Seed random number generator.
Dim seed As New mpz_t()

gmp_lib.mpz_init_set_ui(seed, 100000UI)
gmp_lib.gmp_randseed(state, seed)

' Free all memory occupied by state and seed.
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clear(seed)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randseed_ui


gmp_lib.gmp_randseed_ui Method

gmp_libgmp_randseed_ui Method
Set an initial seed value into state.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void gmp_randseed_ui(
    gmp_randstate_t state,
    uint seed
)
Public Shared Sub gmp_randseed_ui (
    state As gmp_randstate_t,
    seed As UInteger
)
public:
static void gmp_randseed_ui(
    gmp_randstate_t^ state,
    unsigned int seed
)
static member gmp_randseed_ui :
        state : gmp_randstate_t *
        seed : uint32 -> unit

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to seed.
seed
Type: SystemUInt32
The seed.
Remarks

The size of a seed determines how many different sequences of random numbers that it’s possible to generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed used, and this affects the randomness of separate number sequences. The method for choosing a seed is critical if the generated numbers are to be used for important applications, such as generating cryptographic keys.

Traditionally the system time has been used to seed, but care needs to be taken with this. If an application seeds often and the resolution of the system clock is low, then the same sequence of numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is required then it should definitely not be the only source for the seed value. On some systems there’s a special device /dev/random which provides random data better suited for use as a seed.

Examples
C#
VB
C++
F#
Copy
// Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);

// Seed random number generator.
gmp_lib.gmp_randseed_ui(state, 100000U);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
Dim state As New gmp_randstate_t()

gmp_lib.gmp_randinit_mt(state)

' Seed random number generator.
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)        ///

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_randseed


gmp_lib.gmp_scanf Method

gmp_libgmp_scanf Method
Read from the standard input stdin.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_scanf(
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_scanf (
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_scanf(
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_scanf :
        fmt : string *
        ap : Object[] -> int

Parameters

fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

// Read values from standard input.
Assert.IsTrue(gmp_lib.gmp_scanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);

// Assert values read.
Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

' Read values from standard input.
Assert.IsTrue(gmp_lib.gmp_scanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)

' Assert values read.
Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_fscanf
gmp_sscanf
gmp_vscanf


gmp_lib.gmp_snprintf Method

gmp_libgmp_snprintf Method
Form a null-terminated string in buf.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_snprintf(
    char_ptr buf,
    size_t size,
    string fmt,
    params Object[] args
)
Public Shared Function gmp_snprintf (
    buf As char_ptr,
    size As size_t,
    fmt As String,
    ParamArray args As Object()
) As Integer
public:
static int gmp_snprintf(
    char_ptr buf,
    size_t size,
    String^ fmt,
    ... array<Object^>^ args
)
static member gmp_snprintf :
        buf : char_ptr *
        size : size_t *
        fmt : string *
        args : Object[] -> int

Parameters

buf
Type: Math.Gmp.Nativechar_ptr
The string to print to.
size
Type: Math.Gmp.Nativesize_t
The maximum number of bytes to write.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ size then the actual output has been truncated to the first size - 1 characters, and a null appended.
Remarks

No more than size bytes will be written. To get the full output, size must be enough for the string and null-terminator.

No overlap is permitted between the region {buf,size} and the fmt string.

Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style.

Examples
C#
VB
C++
F#
Copy
// Allocate unmanaged string with 50 characters.
char_ptr str = new char_ptr(".................................................");

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to string.
Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Allocate unmanaged string with 50 characters.
Dim str As New char_ptr(".................................................")

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to string.
Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_asprintf
gmp_sprintf
gmp_vsnprintf


gmp_lib.gmp_sprintf Method

gmp_libgmp_sprintf Method
Form a null-terminated string in buf.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_sprintf(
    char_ptr buf,
    string fmt,
    params Object[] args
)
Public Shared Function gmp_sprintf (
    buf As char_ptr,
    fmt As String,
    ParamArray args As Object()
) As Integer
public:
static int gmp_sprintf(
    char_ptr buf,
    String^ fmt,
    ... array<Object^>^ args
)
static member gmp_sprintf :
        buf : char_ptr *
        fmt : string *
        args : Object[] -> int

Parameters

buf
Type: Math.Gmp.Nativechar_ptr
The string to print to.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, excluding the terminating null.
Remarks

No overlap is permitted between the space at buf and the string fmt.

These functions are not recommended, since there’s no protection against exceeding the space available at buf.

Examples
C#
VB
C++
F#
Copy
// Allocate unmanaged string with 50 characters.
char_ptr str = new char_ptr(".................................................");

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to string.
Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Allocate unmanaged string with 50 characters.
Dim str As New char_ptr(".................................................")

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to string.
Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_asprintf
gmp_printf
gmp_fprintf
gmp_snprintf
gmp_vsprintf


gmp_lib.gmp_sscanf Method

gmp_libgmp_sscanf Method
Read from a null-terminated string s.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_sscanf(
    string s,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_sscanf (
    s As String,
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_sscanf(
    String^ s,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_sscanf :
        s : string *
        fmt : string *
        ap : Object[] -> int

Parameters

s
Type: SystemString
A string.
fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);

Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)

Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_fscanf
gmp_scanf
gmp_vsscanf


gmp_lib.gmp_urandomb_ui Method

gmp_libgmp_urandomb_ui Method
Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint gmp_urandomb_ui(
    gmp_randstate_t state,
    uint n
)
Public Shared Function gmp_urandomb_ui (
    state As gmp_randstate_t,
    n As UInteger
) As UInteger
public:
static unsigned int gmp_urandomb_ui(
    gmp_randstate_t^ state,
    unsigned int n
)
static member gmp_urandomb_ui :
        state : gmp_randstate_t *
        n : uint32 -> uint32

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state of the random number generator to use.
n
Type: SystemUInt32
The numbe rof bits.

Return Value

Type: UInt32
The generated random number.
Remarks

n must be less than or equal to the number of bits in an unsigned long.

In .NET, n must be less than or equal to the number of bits in an unsigned 32-bit integer.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 100000U);

// Generate a random integer in the range [0, 2^8-1].
uint rand = gmp_lib.gmp_urandomb_ui(state, 8);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Generate a random integer in the range [0, 2^8-1].
Dim rand As UInteger = gmp_lib.gmp_urandomb_ui(state, 8)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_urandomm_ui


gmp_lib.gmp_urandomm_ui Method

gmp_libgmp_urandomm_ui Method
Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint gmp_urandomm_ui(
    gmp_randstate_t state,
    uint n
)
Public Shared Function gmp_urandomm_ui (
    state As gmp_randstate_t,
    n As UInteger
) As UInteger
public:
static unsigned int gmp_urandomm_ui(
    gmp_randstate_t^ state,
    unsigned int n
)
static member gmp_urandomm_ui :
        state : gmp_randstate_t *
        n : uint32 -> uint32

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state of the random number generator to use.
n
Type: SystemUInt32
The upper bound of the range.

Return Value

Type: UInt32
The generated random number.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 1000U);

// Generate a random integer in the range [0, 8-1].
uint rand = gmp_lib.gmp_urandomm_ui(state, 8);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()

gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 1000UI)

' Generate a random integer in the range [0, 8-1].
Dim rand As UInteger = gmp_lib.gmp_urandomm_ui(state, 8)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_urandomb_ui


gmp_lib.gmp_vasprintf Method

gmp_libgmp_vasprintf Method
Form a null-terminated string in a block of memory obtained from the current memory allocation function.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vasprintf(
    ptr<char_ptr> ptr,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vasprintf (
    ptr As ptr(Of char_ptr),
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vasprintf(
    ptr<char_ptr>^ ptr,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vasprintf :
        ptr : ptr<char_ptr> *
        fmt : string *
        ap : Object[] -> int

Parameters

ptr
Type: Math.Gmp.Nativeptr char_ptr
fmt
Type: SystemString
Format string. See Formatted Output Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value is the number of characters produced, excluding the null-terminator.
Remarks

The block will be the size of the string and null-terminator. The address of the block in stored to ptr.

Unlike the C library vasprintf, gmp_vasprintf doesn’t return -1 if there’s no more memory available, it lets the current allocation function handle that.

Examples
C#
VB
C++
F#
Copy
// Create pointer to unmanaged character string pointer.
ptr<char_ptr> str = new ptr<char_ptr>();

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to newly allocated unmanaged memory string.
Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str.Value);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Create pointer to unmanaged character string pointer.
Dim str As New ptr(Of char_ptr)()

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to newly allocated unmanaged memory string.
Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.Value.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str.Value)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_asprintf


gmp_lib.gmp_vfprintf Method

gmp_libgmp_vfprintf Method
Print to the stream fp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vfprintf(
    ptr<FILE> fp,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vfprintf (
    fp As ptr(Of FILE),
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vfprintf(
    ptr<FILE>^ fp,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vfprintf :
        fp : ptr<FILE> *
        fmt : string *
        ap : Object[] -> int

Parameters

fp
Type: Math.Gmp.Nativeptr FILE
File stream.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, or -1 if an error occurred.
Examples
C#
VB
C++
F#
Copy
// Create unique file pathname and a file pointer.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Open file stream and print to it.
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
fclose(stream.Value.Value);
Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
' Create unique file pathname and a file pointer.
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Open file stream and print to it.
_wfopen_s(stream.Value.Value, pathname, "w")
Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
fclose(stream.Value.Value)
Assert.IsTrue(System.IO.File.ReadAllText(pathname) = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")
' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_fprintf


gmp_lib.gmp_vfscanf Method

gmp_libgmp_vfscanf Method
Read from the stream fp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vfscanf(
    ptr<FILE> fp,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vfscanf (
    fp As ptr(Of FILE),
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vfscanf(
    ptr<FILE>^ fp,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vfscanf :
        fp : ptr<FILE> *
        fmt : string *
        ap : Object[] -> int

Parameters

fp
Type: Math.Gmp.Nativeptr FILE
File stream.
fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
// Create unique filename and stream pointer.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();

mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

// Write string to file, and then read values from it.
System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000");
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
fclose(stream.Value.Value);

// Assert values read.
Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Create unique filename and stream pointer.
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()

Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

' Write string to file, and then read values from it.
System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000")
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)
fclose(stream.Value.Value)

' Assert values read.
Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_fscanf
gmp_vscanf
gmp_vsscanf


gmp_lib.gmp_vprintf Method

gmp_libgmp_vprintf Method
Print to the standard output stdout.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vprintf(
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vprintf (
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vprintf(
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vprintf :
        fmt : string *
        ap : Object[] -> int

Parameters

fmt
Type: SystemString
Format string. See Formatted Output Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, or -1 if an error occurred.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to standard output.
Assert.IsTrue(gmp_lib.gmp_vprintf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);

// Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to standard output.
Assert.IsTrue(gmp_lib.gmp_vprintf("%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_printf


gmp_lib.gmp_vscanf Method

gmp_libgmp_vscanf Method
Read from the standard input stdin.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vscanf(
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vscanf (
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vscanf(
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vscanf :
        fmt : string *
        ap : Object[] -> int

Parameters

fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

// Read values from standard input.
Assert.IsTrue(gmp_lib.gmp_vscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);

// Assert values read.
Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

' Read values from standard input.
Assert.IsTrue(gmp_lib.gmp_vscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)

' Assert values read.
Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_scanf
gmp_vfscanf
gmp_vsscanf


gmp_lib.gmp_vsnprintf Method

gmp_libgmp_vsnprintf Method
Form a null-terminated string in buf.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vsnprintf(
    char_ptr buf,
    size_t size,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vsnprintf (
    buf As char_ptr,
    size As size_t,
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vsnprintf(
    char_ptr buf,
    size_t size,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vsnprintf :
        buf : char_ptr *
        size : size_t *
        fmt : string *
        ap : Object[] -> int

Parameters

buf
Type: Math.Gmp.Nativechar_ptr
The string to print to.
size
Type: Math.Gmp.Nativesize_t
The maximum number of bytes to write.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ size then the actual output has been truncated to the first size - 1 characters, and a null appended.
Remarks

No more than size bytes will be written. To get the full output, size must be enough for the string and null-terminator.

No overlap is permitted between the regiom {buf,size} and the fmt string.

Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style.

Examples
C#
VB
C++
F#
Copy
// Allocate unmanaged string with 50 characters.
char_ptr str = new char_ptr(".................................................");

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to string.
Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Allocate unmanaged string with 50 characters.
Dim str As New char_ptr(".................................................")

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to string.
Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_snprintf


gmp_lib.gmp_vsprintf Method

gmp_libgmp_vsprintf Method
Form a null-terminated string in buf.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vsprintf(
    char_ptr buf,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vsprintf (
    buf As char_ptr,
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vsprintf(
    char_ptr buf,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vsprintf :
        buf : char_ptr *
        fmt : string *
        ap : Object[] -> int

Parameters

buf
Type: Math.Gmp.Nativechar_ptr
The string to print to.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, excluding the terminating null.
Remarks

No overlap is permitted between the space at buf and the string fmt.

These functions are not recommended, since there’s no protection against exceeding the space available at buf.

Examples
C#
VB
C++
F#
Copy
// Allocate unmanaged string with 50 characters.
char_ptr str = new char_ptr(".................................................");

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to string.
Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
' Allocate unmanaged string with 50 characters.
Dim str As New char_ptr(".................................................")

Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456

' Print to string.
Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")

' Release unmanaged memory.
gmp_lib.free(str)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_sprintf


gmp_lib.gmp_vsscanf Method

gmp_libgmp_vsscanf Method
Read from a null-terminated string s.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int gmp_vsscanf(
    string s,
    string fmt,
    params Object[] ap
)
Public Shared Function gmp_vsscanf (
    s As String,
    fmt As String,
    ParamArray ap As Object()
) As Integer
public:
static int gmp_vsscanf(
    String^ s,
    String^ fmt,
    ... array<Object^>^ ap
)
static member gmp_vsscanf :
        s : string *
        fmt : string *
        ap : Object[] -> int

Parameters

s
Type: SystemString
A string.
fmt
Type: SystemString
Format string. See Formatted Input Strings.
ap
Type: SystemObject
Arguments.

Return Value

Type: Int32
The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
Examples
C#
VB
C++
F#
Copy
mpz_t z = "0";
mpq_t q = "0";
mpf_t f = "0";
ptr<Char> c = new ptr<Char>('0');
ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
ptr<Double> dbl = new ptr<Double>(0);

Assert.IsTrue(gmp_lib.gmp_vsscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);

Assert.IsTrue(z.ToString() == "123456");
Assert.IsTrue(q.ToString() == "123/456");
Assert.IsTrue(f.ToString() == "0.12345e11");
Assert.IsTrue(c.Value == 'A');
Assert.IsTrue(zt.Value == 10);
Assert.IsTrue(dbl.Value == 1.0);

// Release unmanaged memory.
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
Dim z As mpz_t = "0"
Dim q As mpq_t = "0"
Dim f As mpf_t = "0"
Dim c As New ptr(Of[Char])("0"C)
Dim zt As New ptr(Of mp_size_t)(0)
Dim dbl As New ptr(Of[Double])(0)

Assert.IsTrue(gmp_lib.gmp_vsscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6)

Assert.IsTrue(z.ToString() = "123456")
Assert.IsTrue(q.ToString() = "123/456")
Assert.IsTrue(f.ToString() = "0.12345e11")
Assert.IsTrue(c.Value = "A"C)
Assert.IsTrue(zt.Value = 10)
Assert.IsTrue(dbl.Value = 1.0)

' Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
gmp_sscanf
gmp_vfscanf
gmp_vscanf


gmp_lib.mp_get_memory_functions Method

gmp_libmp_get_memory_functions Method
Get the current allocation functions, storing function pointers to the locations given by the arguments.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mp_get_memory_functions(
    ref allocate_function alloc_func_ptr,
    ref reallocate_function realloc_func_ptr,
    ref free_function free_func_ptr
)
Public Shared Sub mp_get_memory_functions (
    ByRef alloc_func_ptr As allocate_function,
    ByRef realloc_func_ptr As reallocate_function,
    ByRef free_func_ptr As free_function
)
public:
static void mp_get_memory_functions(
    allocate_function^% alloc_func_ptr,
    reallocate_function^% realloc_func_ptr,
    free_function^% free_func_ptr
)
static member mp_get_memory_functions :
        alloc_func_ptr : allocate_function byref *
        realloc_func_ptr : reallocate_function byref *
        free_func_ptr : free_function byref -> unit

Parameters

alloc_func_ptr
Type: Math.Gmp.Nativeallocate_function
The memory allocation function.
realloc_func_ptr
Type: Math.Gmp.Nativereallocate_function
The memory reallocation function.
free_func_ptr
Type: Math.Gmp.Nativefree_function
The memory de-allocation function.
Examples
C#
VB
C++
F#
Copy
allocate_function allocate;
reallocate_function reallocate;
free_function free;

// Retrieve the GMP memory allocation functions.
allocate = null;
reallocate = null;
free = null;
gmp_lib.mp_get_memory_functions(ref allocate, ref reallocate, ref free);
Assert.IsTrue(allocate != null && reallocate != null && free != null);

// Allocate and free memory.
void_ptr p = allocate(100);
free(p, 100);
Dim allocate As allocate_function
Dim reallocate As reallocate_function
Dim free As free_function

' Retrieve the GMP memory allocation functions.
allocate = Nothing
reallocate = Nothing
free = Nothing
gmp_lib.mp_get_memory_functions(allocate, reallocate, free)
Assert.IsTrue(allocate IsNot Nothing AndAlso reallocate IsNot Nothing AndAlso free IsNot Nothing)

' Allocate and free memory.
Dim p As void_ptr = allocate(100)
free(p, 100)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mp_set_memory_functions


gmp_lib.mp_set_memory_functions Method

gmp_libmp_set_memory_functions Method
Replace the current allocation functions from the arguments.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mp_set_memory_functions(
    allocate_function alloc_func_ptr,
    reallocate_function realloc_func_ptr,
    free_function free_func_ptr
)
Public Shared Sub mp_set_memory_functions (
    alloc_func_ptr As allocate_function,
    realloc_func_ptr As reallocate_function,
    free_func_ptr As free_function
)
public:
static void mp_set_memory_functions(
    allocate_function^ alloc_func_ptr,
    reallocate_function^ realloc_func_ptr,
    free_function^ free_func_ptr
)
static member mp_set_memory_functions :
        alloc_func_ptr : allocate_function *
        realloc_func_ptr : reallocate_function *
        free_func_ptr : free_function -> unit

Parameters

alloc_func_ptr
Type: Math.Gmp.Nativeallocate_function
The new memory allocation function.
realloc_func_ptr
Type: Math.Gmp.Nativereallocate_function
The new memory reallocation function.
free_func_ptr
Type: Math.Gmp.Nativefree_function
The new memory de-allocation function.
Remarks

If an argument is null (Nothing in VB.NET), the corresponding default function is used.

Examples
C#
VB
C++
F#
Copy
// Retrieve GMP default memory allocation functions.
allocate_function default_allocate = null;
reallocate_function default_reallocate = null;
free_function default_free = null;
gmp_lib.mp_get_memory_functions(ref default_allocate, ref default_reallocate, ref default_free);

// Create and set new memory allocation functions that count the number of times they are called.
int counter = 0;
allocate_function new_allocate = (size_t alloc_size) => { counter++; return default_allocate(alloc_size); };
reallocate_function new_reallocate = (void_ptr ptr, size_t old_size, size_t new_size) => { counter++; return default_reallocate(ptr, old_size, new_size); };
free_function new_free = (void_ptr ptr, size_t size) => { counter++; default_free(ptr, size); };
gmp_lib.mp_set_memory_functions(new_allocate, new_reallocate, new_free);

// Retrieve GMP memory allocation functions.
allocate_function allocate = null;
reallocate_function reallocate = null;
free_function free = null;
gmp_lib.mp_get_memory_functions(ref allocate, ref reallocate, ref free);

// Call memory function and assert calls count.
void_ptr p = allocate(10);
Assert.IsTrue(counter == 1);

reallocate(p, 10, 20);
Assert.IsTrue(counter == 2);

free(p, 20);
Assert.IsTrue(counter == 3);

// Restore default memory allocation functions.
gmp_lib.mp_set_memory_functions(null, null, null);
' Retrieve GMP default memory allocation functions.
Dim default_allocate As allocate_function = Nothing
Dim default_reallocate As reallocate_function = Nothing
Dim default_free As free_function = Nothing
gmp_lib.gmp_get_memory_functions(default_allocate, default_reallocate, default_free)

' Create and set new memory allocation functions that count the number of times they are called.
Dim counter As Integer = 0
Dim new_allocate As allocate_function =
    Function(alloc_size As size_t)
        counter += 1
        Return default_allocate(alloc_size)
    End Function
Dim new_reallocate As reallocate_function =
    Function(ptr As void_ptr, old_size As size_t, new_size As size_t)
        counter += 1
        Return default_reallocate(ptr, old_size, new_size)
    End Function
Dim new_free As free_function =
    Function(ptr As void_ptr, size As size_t)
        counter += 1
        default_free(ptr, size)
    End Function
gmp_lib.gmp_set_memory_functions(new_allocate, new_reallocate, new_free)

' Retrieve GMP memory allocation functions.
Dim allocate As allocate_function = Nothing
Dim reallocate As reallocate_function = Nothing
Dim free As free_function = Nothing
gmp_lib.gmp_get_memory_functions(allocate, reallocate, free)

' Call memory function and assert calls count.
Dim p As void_ptr = allocate(10)
Assert.IsTrue(counter = 1)

reallocate(p, 10, 20)
Assert.IsTrue(counter = 2)

free(p, 20)
Assert.IsTrue(counter = 3)

' Restore default memory allocation functions.
gmp_lib.gmp_set_memory_functions(Nothing, Nothing, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mp_get_memory_functions


gmp_lib.mpf_abs Method

gmp_libmpf_abs Method
Set rop to | op |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_abs(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_abs (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_abs(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_abs :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to -10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, -10);

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

// Set z = |x|.
gmp_lib.mpf_abs(z, x);

// Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to -10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, -10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = |x|.
gmp_lib.mpf_absg(z, x)

' Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_add Method

gmp_libmpf_add Method
Set rop to op1 + op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_add(
    mpf_t rop,
    mpf_t op1,
    mpf_t op2
)
Public Shared Sub mpf_add (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mpf_t
)
public:
static void mpf_add(
    mpf_t^ rop,
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_add :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = x + y.
gmp_lib.mpf_add(z, x, y);

// Assert that the value of z is -200.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -200.0);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x + y.
gmp_lib.mpf_add(z, x, y)

' Assert that the value of z is -200.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = -200.0)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add_ui
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_add_ui Method

gmp_libmpf_add_ui Method
Set rop to op1 + op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_add_ui(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_add_ui (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_add_ui(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_add_ui :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: SystemUInt32
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = x + 210.
gmp_lib.mpf_add_ui(z, x, 210U);

// Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x + 210.
gmp_lib.mpf_add_ui(z, x, 210UI)

' Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_ceil Method

gmp_libmpf_ceil Method
Set rop to op rounded to the next higher integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_ceil(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_ceil (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_ceil(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_ceil :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand float.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.4.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, 10.4);

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

// Set z = ceil(x).
gmp_lib.mpf_ceil(z, x);

// Assert that the value of z is 11.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 11.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.4.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, 10.4)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = ceil(x).
gmp_lib.mpf_ceil(z, x)

' Assert that the value of z is 11.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 11.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_clear Method

gmp_libmpf_clear Method
Free the space occupied by x.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_clear(
    mpf_t x
)
Public Shared Sub mpf_clear (
    x As mpf_t
)
public:
static void mpf_clear(
    mpf_t^ x
)
static member mpf_clear :
        x : mpf_t -> unit

Parameters

x
Type: Math.Gmp.Nativempf_t
The operand float.
Remarks

Make sure to call this function for all mpf_t variables when you are done with them.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

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

// Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create and initialize a new floating-point number x.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)

' Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_clears Method

gmp_libmpf_clears Method
Free the space occupied by a NULL-terminated list of mpf_t variables.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_clears(
    params mpf_t[] x
)
Public Shared Sub mpf_clears (
    ParamArray x As mpf_t()
)
public:
static void mpf_clears(
    ... array<mpf_t^>^ x
)
static member mpf_clears :
        x : mpf_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempf_t
The operand float.
Examples
C#
VB
C++
F#
Copy
// Create new floating-point numbers x1, x2 and x3.
mpf_t x1 = new mpf_t();
mpf_t x2 = new mpf_t();
mpf_t x3 = new mpf_t();

// Initialize the floating-point numbers.
gmp_lib.mpf_inits(x1, x2, x3, null);

// Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0);
Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0);
Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0);

// Release unmanaged memory allocated for the floating-point numbers.
gmp_lib.mpf_clears(x1, x2, x3, null);
' Create new floating-point numbers x1, x2 and x3.
Dim x1 As New mpf_t()
Dim x2 As New mpf_t()
Dim x3 As New mpf_t()

' Initialize the floating-point numbers.
gmp_lib.mpf_inits(x1, x2, x3, Nothing)

' Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpf_get_d(x1) = 0.0)
Assert.IsTrue(gmp_lib.mpf_get_d(x2) = 0.0)
Assert.IsTrue(gmp_lib.mpf_get_d(x3) = 0.0)

' Release unmanaged memory allocated for the floating-point numbers.
gmp_lib.mpf_clears(x1, x2, x3, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_cmp Method

gmp_libmpf_cmp Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_cmp(
    mpf_t op1,
    mpf_t op2
)
Public Shared Function mpf_cmp (
    op1 As mpf_t,
    op2 As mpf_t
) As Integer
public:
static int mpf_cmp(
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_cmp :
        op1 : mpf_t *
        op2 : mpf_t -> int

Parameters

op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: Math.Gmp.Nativempf_t
The second operand float.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

// Create and initialize a new floating-point number z.
mpf_t z = new mpf_t();
gmp_lib.mpf_init_set_si(z, 128);

// Assert that x > z.
Assert.IsTrue(gmp_lib.mpf_cmp(x, z) > 0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 512)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init_set_si(z, 128)

' Assert that x > z.
Assert.IsTrue(gmp_lib.mpf_cmp(x, z) > 0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp_z
mpf_cmp_d
mpf_cmp_ui
mpf_cmp_si
mpf_reldiff
mpf_sgn


gmp_lib.mpf_cmp_d Method

gmp_libmpf_cmp_d Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_cmp_d(
    mpf_t op1,
    double op2
)
Public Shared Function mpf_cmp_d (
    op1 As mpf_t,
    op2 As Double
) As Integer
public:
static int mpf_cmp_d(
    mpf_t^ op1,
    double op2
)
static member mpf_cmp_d :
        op1 : mpf_t *
        op2 : float -> int

Parameters

op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: SystemDouble
The second operand float.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Remarks

mpf_cmp_d can be called with an infinity, but results are undefined for a NaN.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

// Assert that x > 128.0.
Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 512)

' Assert that x > 128.0.
Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_z
mpf_cmp_ui
mpf_cmp_si
mpf_reldiff
mpf_sgn


gmp_lib.mpf_cmp_si Method

gmp_libmpf_cmp_si Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_cmp_si(
    mpf_t op1,
    int op2
)
Public Shared Function mpf_cmp_si (
    op1 As mpf_t,
    op2 As Integer
) As Integer
public:
static int mpf_cmp_si(
    mpf_t^ op1,
    int op2
)
static member mpf_cmp_si :
        op1 : mpf_t *
        op2 : int -> int

Parameters

op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: SystemInt32
The second operand float.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

// Assert that x > 128.
Assert.IsTrue(gmp_lib.mpf_cmp_si(x, 128) > 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()

gmp_lib.mpf_init_set_si(x, 512)

' Assert that x > 128.
Assert.IsTrue(gmp_lib.mpf_cmp_si(x, 128) > 0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_z
mpf_cmp_d
mpf_cmp_ui
mpf_reldiff
mpf_sgn


gmp_lib.mpf_cmp_ui Method

gmp_libmpf_cmp_ui Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_cmp_ui(
    mpf_t op1,
    uint op2
)
Public Shared Function mpf_cmp_ui (
    op1 As mpf_t,
    op2 As UInteger
) As Integer
public:
static int mpf_cmp_ui(
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_cmp_ui :
        op1 : mpf_t *
        op2 : uint32 -> int

Parameters

op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: SystemUInt32
The second operand float.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

// Assert that x > 128.
Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 512)

' Assert that x > 128.
Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_z
mpf_cmp_d
mpf_cmp_si
mpf_reldiff
mpf_sgn


gmp_lib.mpf_cmp_z Method

gmp_libmpf_cmp_z Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_cmp_z(
    mpf_t op1,
    mpz_t op2
)
Public Shared Function mpf_cmp_z (
    op1 As mpf_t,
    op2 As mpz_t
) As Integer
public:
static int mpf_cmp_z(
    mpf_t^ op1,
    mpz_t^ op2
)
static member mpf_cmp_z :
        op1 : mpf_t *
        op2 : mpz_t -> int

Parameters

op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: Math.Gmp.Nativempz_t
The second operand float.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

// Create and initialize a new integer z.
mpz_t z = new mpz_t();
gmp_lib.mpz_init_set_si(z, 128);

// Assert that x > z.
Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clear(x);
gmp_lib.mpz_clear(z);
///
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 512)

' Create and initialize a new integer z.
Dim z As New mpz_t()
gmp_lib.mpz_init_set_si(z, 128)

' Assert that x > z.
Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_d
mpf_cmp_ui
mpf_cmp_si
mpf_reldiff
mpf_sgn


gmp_lib.mpf_div Method

gmp_libmpf_div Method
Set rop to op1 / op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_div(
    mpf_t rop,
    mpf_t op1,
    mpf_t op2
)
Public Shared Sub mpf_div (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mpf_t
)
public:
static void mpf_div(
    mpf_t^ rop,
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_div :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Remarks

Division is undefined if the divisor is zero, and passing a zero divisor to the divide functions will make it intentionally divide by zero. This lets the user handle arithmetic exceptions in division functions in the same manner as other arithmetic exceptions.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = y / x.
gmp_lib.mpf_div(z, y, x);

// Assert that the value of z is -21.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = y / x.
gmp_lib.mpf_div(z, y, x)

' Assert that the value of z is -21.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = -21.0)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_ui_div
mpf_div_ui
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs
mpf_div_2exp


gmp_lib.mpf_div_2exp Method

gmp_libmpf_div_2exp Method
Set rop to op1 / 2^op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_div_2exp(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_div_2exp (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_div_2exp(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_div_2exp :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The fisrt operand.
op2
Type: SystemUInt32
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 512.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 512);

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

// Set z = x / 2^8.
gmp_lib.mpf_div_2exp(z, x, 8U);

// Assert that the value of z is 2.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 512.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 512)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x / 2^8.
gmp_lib.mpf_div_2exp(z, x, 8UI)

' Assert that the value of z is 2.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 2.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_ui_div
mpf_div_ui
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_div_ui Method

gmp_libmpf_div_ui Method
Set rop to op1 / op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_div_ui(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_div_ui (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_div_ui(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_div_ui :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: SystemUInt32
The second operand.
Remarks

Division is undefined if the divisor is zero, and passing a zero divisor to the divide functions will make it intentionally divide by zero. This lets the user handle arithmetic exceptions in division functions in the same manner as other arithmetic exceptions.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = y / 10.
gmp_lib.mpf_div_ui(z, y, 10U);

// Assert that the value of z is -21.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0);

// Release unmanaged memory allocated for y and z.
gmp_lib.mpf_clears(y, z, null);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_ui_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs
mpf_div_2exp


gmp_lib.mpf_fits_sint_p Method

gmp_libmpf_fits_sint_p Method
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_sint_p(
    mpf_t op
)
Public Shared Function mpf_fits_sint_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_sint_p(
    mpf_t^ op
)
static member mpf_fits_sint_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) = 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_fits_slong_p Method

gmp_libmpf_fits_slong_p Method
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_slong_p(
    mpf_t op
)
Public Shared Function mpf_fits_slong_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_slong_p(
    mpf_t^ op
)
static member mpf_fits_slong_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in long.
Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in long.
Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) = 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_fits_sshort_p Method

gmp_libmpf_fits_sshort_p Method
Return non-zero if op fits in a 16-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_sshort_p(
    mpf_t op
)
Public Shared Function mpf_fits_sshort_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_sshort_p(
    mpf_t^ op
)
static member mpf_fits_sshort_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in short.
Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in short.
Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) = 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_fits_uint_p Method

gmp_libmpf_fits_uint_p Method
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_uint_p(
    mpf_t op
)
Public Shared Function mpf_fits_uint_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_uint_p(
    mpf_t^ op
)
static member mpf_fits_uint_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in uint.
Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in uint.
Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_fits_ulong_p Method

gmp_libmpf_fits_ulong_p Method
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_ulong_p(
    mpf_t op
)
Public Shared Function mpf_fits_ulong_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_ulong_p(
    mpf_t^ op
)
static member mpf_fits_ulong_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) = 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_fits_ushort_p Method

gmp_libmpf_fits_ushort_p Method
Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_fits_ushort_p(
    mpf_t op
)
Public Shared Function mpf_fits_ushort_p (
    op As mpf_t
) As Integer
public:
static int mpf_fits_ushort_p(
    mpf_t^ op
)
static member mpf_fits_ushort_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in ushort.
Assert.IsTrue(gmp_lib.mpf_fits_ushort_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in ushort.
Assert.IsTrue(gmp_lib.mpf_fits_ushort_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op)
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_floor Method

gmp_libmpf_floor Method
Set rop to op rounded to the next lower integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_floor(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_floor (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_floor(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_floor :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand float.
Examples
C#
VB
C++
F#
Copy
/ Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.4.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, 10.4);

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

// Set z = floor(x).
gmp_lib.mpf_floor(z, x);

// Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.4.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, 10.4)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = floor(x).
gmp_lib.mpf_floor(z, x)

' Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_get_d Method

gmp_libmpf_get_d Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static double mpf_get_d(
    mpf_t op
)
Public Shared Function mpf_get_d (
    op As mpf_t
) As Double
public:
static double mpf_get_d(
    mpf_t^ op
)
static member mpf_get_d :
        op : mpf_t -> float

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Double
The cpnverted double.
Remarks

If the exponent in op is too big or too small to fit a double then the result is system dependent. For too big an infinity is returned when available. For too small 0.0 is normally returned. Hardware overflow, underflow and denorm traps may or may not occur.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -123.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -123.0);

// Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -123.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -123.0)

' Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_get_d_2exp
mpf_get_si
mpf_get_ui
O:Math.Gmp.Native.gmp_lib.mpf_get_str


gmp_lib.mpf_get_d_2exp Method

gmp_libmpf_get_d_2exp Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static double mpf_get_d_2exp(
    ptr<int> exp,
    mpf_t op
)
Public Shared Function mpf_get_d_2exp (
    exp As ptr(Of Integer),
    op As mpf_t
) As Double
public:
static double mpf_get_d_2exp(
    ptr<int>^ exp,
    mpf_t^ op
)
static member mpf_get_d_2exp :
        exp : ptr<int> *
        op : mpf_t -> float

Parameters

exp
Type: Math.Gmp.Nativeptr Int32
Pointer to 32-bit signed integer.
op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Double
The return value is in the range 0.5 ≤ | d | < 1 and the exponent is stored at exp. d * 2^exp is the (truncated) op value. If op is zero, the return is 0.0 and 0 is stored at exp.
Remarks

This is similar to the standard C frexp function (see GNU C - Normalization Functions in The GNU C Library Reference Manual).

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -8.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -8.0);

// Assert that the absolute value of x is 0.5 x 2^4.
ptr<int> exp = new ptr<int>(0);
Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) == 0.5);
Assert.IsTrue(exp.Value == 4);

// Release unmanaged memory allocated for x and exp.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -8.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -8.0)

' Assert that the absolute value of x is 0.5 x 2^4.
Dim exp As New ptr(Of Integer)(0)
Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) = 0.5)
Assert.IsTrue(exp.Value = 4)

' Release unmanaged memory allocated for x and exp.
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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_get_d
mpf_get_si
mpf_get_ui
O:Math.Gmp.Native.gmp_lib.mpf_get_str


gmp_lib.mpf_get_default_prec Method

gmp_libmpf_get_default_prec Method
Return the default precision actually used.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpf_get_default_prec()
Public Shared Function mpf_get_default_prec As mp_bitcnt_t
public:
static mp_bitcnt_t mpf_get_default_prec()
static member mpf_get_default_prec : unit -> mp_bitcnt_t

Return Value

Type: mp_bitcnt_t
The default precision actually used.
Remarks

An mpf_t object must be initialized before storing the first value in it. The functions mpf_init and mpf_init2 are used for that purpose.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128U);

// Assert that the value of x is 128 bits.
Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U);
' Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128UI)

' Assert that the value of x is 128 bits.
Assert.IsTrue(gmp_lib.mpf_get_default_prec() = 128UI)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_get_prec Method

gmp_libmpf_get_prec Method
Return the current precision of op, in bits.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpf_get_prec(
    mpf_t op
)
Public Shared Function mpf_get_prec (
    op As mpf_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpf_get_prec(
    mpf_t^ op
)
static member mpf_get_prec :
        op : mpf_t -> mp_bitcnt_t

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: mp_bitcnt_t
The current precision of op, in bits.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new floating-point number x with 64-bit precision.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(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 with 64-bit precision.
Dim x As New mpf_t()
gmp_lib.mpf_init2(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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_get_si Method

gmp_libmpf_get_si Method
Convert op to a 32-bit integer, truncating any fraction part.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_get_si(
    mpf_t op
)
Public Shared Function mpf_get_si (
    op As mpf_t
) As Integer
public:
static int mpf_get_si(
    mpf_t^ op
)
static member mpf_get_si :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
The converted integer.
Remarks

If op is too big for the return type, the result is undefined.

See also mpf_fits_slong_p and mpf_fits_ulong_p (see GNU MP - Miscellaneous Float Functions).

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -8.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -8.0);

// Assert that the value of x is -8.
Assert.IsTrue(gmp_lib.mpf_get_si(x) == -8);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -8.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -8.0)

' Assert that the value of x is -8.
Assert.IsTrue(gmp_lib.mpf_get_si(x) = -8)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_get_d
mpf_get_d_2exp
mpf_get_ui
O:Math.Gmp.Native.gmp_lib.mpf_get_str


gmp_lib.mpf_get_str Method

gmp_libmpf_get_str Method
Overload List
Name | Description
mpf_get_str(char_ptr, mp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
mpf_get_str(char_ptr, ptrmp_exp_t, Int32, size_t, mpf_t) | Convert op to a string of digits in base base.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpf_get_str Method (char_ptr, mp_exp_t, Int32, size_t, mpf_t)

gmp_libmpf_get_str Method (char_ptr, mp_exp_t, Int32, size_t, mpf_t)
Convert op to a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static char_ptr mpf_get_str(
    char_ptr str,
    ref mp_exp_t expptr,
    int base,
    size_t n_digits,
    mpf_t op
)
Public Shared Function mpf_get_str (
    str As char_ptr,
    ByRef expptr As mp_exp_t,
    base As Integer,
    n_digits As size_t,
    op As mpf_t
) As char_ptr
public:
static char_ptr mpf_get_str(
    char_ptr str,
    mp_exp_t% expptr,
    int base,
    size_t n_digits,
    mpf_t^ op
)
static member mpf_get_str :
        str : char_ptr *
        expptr : mp_exp_t byref *
        base : int *
        n_digits : size_t *
        op : mpf_t -> char_ptr

Parameters

str
Type: Math.Gmp.Nativechar_ptr
The output string.
expptr
Type: Math.Gmp.Nativemp_exp_t
The exponent.
base
Type: SystemInt32
The base.
n_digits
Type: Math.Gmp.Nativesize_t
Maximum number of output digits.
op
Type: Math.Gmp.Nativempf_t
The operand floating-point number.

Return Value

Type: char_ptr
A pointer to the result string is returned, being either the allocated block or the given str.
Remarks

The base argument may vary from 2 to 62 or from -2 to -36. Up to n_digits digits will be generated. Trailing zeros are not returned. No more digits than can be accurately represented by op are ever generated. If n_digits is 0 then that accurate maximum number of digits are generated.

For base in the range 2..36, digits and lower-case letters are used; for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.

If str is NULL, the result string is allocated using the current allocation function (see GNU MP - Custom Allocation). The block will be strlen(str) + 1 bytes, that being exactly enough for the string and null-terminator.

If str is not NULL, it should point to a block of n_digits + 2 bytes, that being enough for the mantissa, a possible minus sign, and a null-terminator. When n_digits is 0 to get all significant digits, an application won’t be able to know the space required, and str should be NULL in that case.

The generated string is a fraction, with an implicit radix point immediately to the left of the first digit. The applicable exponent is written through the expptr pointer. For example, the number 3.1416 would be returned as string "31416" and exponent 1.

When op is zero, an empty string is produced and the exponent returned is 0.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -8.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -8.0);

// Assert that the value of x is -8.
mp_exp_t exp = 0;
char_ptr value = gmp_lib.mpf_get_str(char_ptr.Zero, ref exp, 10, 0, x);
Assert.IsTrue(value.ToString() == "-8");
Assert.IsTrue(exp == 1);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -8.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -8.0)

' Assert that the value of x is -8.
Dim exp As mp_exp_t = 0
Dim value As char_ptr = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x)
Assert.IsTrue(value.ToString() = "-8")
Assert.IsTrue(exp = 1)

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

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

Reference

gmp_lib Class
mpf_get_str Overload
Math.Gmp.Native Namespace
mpf_get_d
mpf_get_d_2exp
mpf_get_si
mpf_get_ui


gmp_lib.mpf_get_str Method (char_ptr, ptr(mp_exp_t), Int32, size_t, mpf_t)

gmp_libmpf_get_str Method (char_ptr, ptrmp_exp_t, Int32, size_t, mpf_t)
Convert op to a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static char_ptr mpf_get_str(
    char_ptr str,
    ptr<mp_exp_t> expptr,
    int base,
    size_t n_digits,
    mpf_t op
)
Public Shared Function mpf_get_str (
    str As char_ptr,
    expptr As ptr(Of mp_exp_t),
    base As Integer,
    n_digits As size_t,
    op As mpf_t
) As char_ptr
public:
static char_ptr mpf_get_str(
    char_ptr str,
    ptr<mp_exp_t>^ expptr,
    int base,
    size_t n_digits,
    mpf_t^ op
)
static member mpf_get_str :
        str : char_ptr *
        expptr : ptr<mp_exp_t> *
        base : int *
        n_digits : size_t *
        op : mpf_t -> char_ptr

Parameters

str
Type: Math.Gmp.Nativechar_ptr
The output string.
expptr
Type: Math.Gmp.Nativeptr mp_exp_t
The exponent.
base
Type: SystemInt32
The base.
n_digits
Type: Math.Gmp.Nativesize_t
Maximum number of output digits.
op
Type: Math.Gmp.Nativempf_t
The operand floating-point number.

Return Value

Type: char_ptr
A pointer to the result string is returned, being either the allocated block or the given str.
Remarks

The base argument may vary from 2 to 62 or from -2 to -36. Up to n_digits digits will be generated. Trailing zeros are not returned. No more digits than can be accurately represented by op are ever generated. If n_digits is 0 then that accurate maximum number of digits are generated.

For base in the range 2..36, digits and lower-case letters are used; for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.

If str is NULL, the result string is allocated using the current allocation function (see GNU MP - Custom Allocation). The block will be strlen(str) + 1 bytes, that being exactly enough for the string and null-terminator.

If str is not NULL, it should point to a block of n_digits + 2 bytes, that being enough for the mantissa, a possible minus sign, and a null-terminator. When n_digits is 0 to get all significant digits, an application won’t be able to know the space required, and str should be NULL in that case.

The generated string is a fraction, with an implicit radix point immediately to the left of the first digit. The applicable exponent is written through the expptr pointer. For example, the number 3.1416 would be returned as string "31416" and exponent 1.

When op is zero, an empty string is produced and the exponent returned is 0.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -8.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -8.0);

// Assert that the value of x is -8.
ptr<mp_exp_t> exp = new ptr<mp_exp_t>(0);
char_ptr value = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x);
Assert.IsTrue(value.ToString() == "-8");
Assert.IsTrue(exp.Value == 1);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -8.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -8.0)

' Assert that the value of x is -8.
Dim exp As New ptr(Of mp_exp_t)(0)
Dim value As char_ptr = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x)
Assert.IsTrue(value.ToString() = "-8")
Assert.IsTrue(exp.Value = 1)

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

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

Reference

gmp_lib Class
mpf_get_str Overload
Math.Gmp.Native Namespace
mpf_get_d
mpf_get_d_2exp
mpf_get_si
mpf_get_ui


gmp_lib.mpf_get_ui Method

gmp_libmpf_get_ui Method
Convert op to an unsigned 32-bit integer, truncating any fraction part.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpf_get_ui(
    mpf_t op
)
Public Shared Function mpf_get_ui (
    op As mpf_t
) As UInteger
public:
static unsigned int mpf_get_ui(
    mpf_t^ op
)
static member mpf_get_ui :
        op : mpf_t -> uint32

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: UInt32
The converted integer.
Remarks

If op is too big for the return type, the result is undefined.

See also mpf_fits_slong_p and mpf_fits_ulong_p (see GNU MP - Miscellaneous Float Functions).

Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpf_get_d
mpf_get_d_2exp
mpf_get_si
O:Math.Gmp.Native.gmp_lib.mpf_get_str


gmp_lib.mpf_init Method

gmp_libmpf_init Method
Initialize x to 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_init(
    mpf_t x
)
Public Shared Sub mpf_init (
    x As mpf_t
)
public:
static void mpf_init(
    mpf_t^ x
)
static member mpf_init :
        x : mpf_t -> unit

Parameters

x
Type: Math.Gmp.Nativempf_t
The operand float.
Remarks

Normally, a variable should be initialized once only or at least be cleared, using mpf_clear, between initializations. The precision of x is undefined unless a default precision has already been established by a call to mpf_set_default_prec.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

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

// Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create and initialize a new floating-point number x.
Dim x As New mpf_t()

gmp_lib.mpf_init(x)

' Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_init_set Method

gmp_libmpf_init_set Method
Initialize rop and set its value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_init_set(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_init_set (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_init_set(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_init_set :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand.
Remarks

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

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to x.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set(y, x);

// Assert that the value of y is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to x.
Dim y As New mpf_t()
gmp_lib.mpf_init_set(y, x)

' Assert that the value of y is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(y) = 10.0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_init_set_ui
mpf_init_set_si
mpf_init_set_d
mpf_init_set_str


gmp_lib.mpf_init_set_d Method

gmp_libmpf_init_set_d Method
Initialize rop and set its value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_init_set_d(
    mpf_t rop,
    double op
)
Public Shared Sub mpf_init_set_d (
    rop As mpf_t,
    op As Double
)
public:
static void mpf_init_set_d(
    mpf_t^ rop,
    double op
)
static member mpf_init_set_d :
        rop : mpf_t *
        op : float -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemDouble
The operand.
Remarks

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

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -123.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -123.0);

// Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to -123.0
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, -123.0)

' Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_init_set
mpf_init_set_ui
mpf_init_set_si
mpf_init_set_str


gmp_lib.mpf_init_set_si Method

gmp_libmpf_init_set_si Method
Initialize rop and set its value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_init_set_si(
    mpf_t rop,
    int op
)
Public Shared Sub mpf_init_set_si (
    rop As mpf_t,
    op As Integer
)
public:
static void mpf_init_set_si(
    mpf_t^ rop,
    int op
)
static member mpf_init_set_si :
        rop : mpf_t *
        op : int -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemInt32
The operand.
Remarks

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

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize and set a new floating-point number to -123.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, -123);

// Assert that the value of x is -123.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize and set a new floating-point number to -123.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, -123)

' Assert that the value of x is -123.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_init_set
mpf_init_set_ui
mpf_init_set_d
mpf_init_set_str


gmp_lib.mpf_init_set_str Method

gmp_libmpf_init_set_str Method
Initialize rop and set its value from the string in str.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_init_set_str(
    mpf_t rop,
    char_ptr str,
    int base
)
Public Shared Function mpf_init_set_str (
    rop As mpf_t,
    str As char_ptr,
    base As Integer
) As Integer
public:
static int mpf_init_set_str(
    mpf_t^ rop,
    char_ptr str,
    int base
)
static member mpf_init_set_str :
        rop : mpf_t *
        str : char_ptr *
        base : int -> int

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
str
Type: Math.Gmp.Nativechar_ptr
The operand string.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
This function returns 0 if the entire string is a valid number in base base. Otherwise it returns -1.
Remarks

See mpf_set_str 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.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 0.0234.
char_ptr value = new char_ptr("234e-4");
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_str(x, value, 10);

// Assert that x is 40.
Assert.IsTrue(x.ToString() == "0.234e-1");

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 0.0234.
Dim value As New char_ptr("234e-4")
Dim x As New mpf_t()
gmp_lib.mpf_init_set_str(x, value, 10)

' Assert that x is 40.
Assert.IsTrue(x.ToString() = "0.234e-1")

' Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_init_set
mpf_init_set_ui
mpf_init_set_si
mpf_init_set_d


gmp_lib.mpf_init_set_ui Method

gmp_libmpf_init_set_ui Method
Initialize rop and set its value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_init_set_ui(
    mpf_t rop,
    uint op
)
Public Shared Sub mpf_init_set_ui (
    rop As mpf_t,
    op As UInteger
)
public:
static void mpf_init_set_ui(
    mpf_t^ rop,
    unsigned int op
)
static member mpf_init_set_ui :
        rop : mpf_t *
        op : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemUInt32
The operand.
Remarks

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

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to 100.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_ui(x, 100U);

// Assert that the value of x is 100.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number to 100.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_ui(x, 100UI)

' Assert that the value of x is 100.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = 100.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_init_set
mpf_init_set_si
mpf_init_set_d
mpf_init_set_str


gmp_lib.mpf_init2 Method

gmp_libmpf_init2 Method
Initialize x to 0 and set its precision 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
C#
VB
C++
F#
Copy
public static void mpf_init2(
    mpf_t x,
    mp_bitcnt_t prec
)
Public Shared Sub mpf_init2 (
    x As mpf_t,
    prec As mp_bitcnt_t
)
public:
static void mpf_init2(
    mpf_t^ x,
    mp_bitcnt_t prec
)
static member mpf_init2 :
        x : mpf_t *
        prec : mp_bitcnt_t -> unit

Parameters

x
Type: Math.Gmp.Nativempf_t
The operand float.
prec
Type: Math.Gmp.Nativemp_bitcnt_t
The minimum precision in bits.
Remarks

Normally, a variable should be initialized once only or at least be cleared, using mpf_clear, between initializations.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new floating-point number x with 64-bit precision.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(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);
uint p = gmp_lib.mpf_get_prec(x);
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 with 64-bit precision.
Dim x As New mpf_t()
gmp_lib.mpf_init2(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)
Dim p As UInteger = gmp_lib.mpf_get_prec(x)
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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_inits Method

gmp_libmpf_inits Method
Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_inits(
    params mpf_t[] x
)
Public Shared Sub mpf_inits (
    ParamArray x As mpf_t()
)
public:
static void mpf_inits(
    ... array<mpf_t^>^ x
)
static member mpf_inits :
        x : mpf_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempf_t
The operand float.
Remarks

The precision of the initialized variables is undefined unless a default precision has already been established by a call to mpf_set_default_prec.

Examples
C#
VB
C++
F#
Copy
// Create new floating-point numbers x1, x2 and x3.
mpf_t x1 = new mpf_t();
mpf_t x2 = new mpf_t();
mpf_t x3 = new mpf_t();

// Initialize the floating-point numbers.
gmp_lib.mpf_inits(x1, x2, x3, null);

// Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0);
Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0);
Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0);

// Release unmanaged memory allocated for the floating-point numbers.
gmp_lib.mpf_clears(x1, x2, x3, null);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_inp_str Method

gmp_libmpf_inp_str Method
Read a string in base base from stream, and put the read float in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpf_inp_str(
    mpf_t rop,
    ptr<FILE> stream,
    int base
)
Public Shared Function mpf_inp_str (
    rop As mpf_t,
    stream As ptr(Of FILE),
    base As Integer
) As size_t
public:
static size_t mpf_inp_str(
    mpf_t^ rop,
    ptr<FILE>^ stream,
    int base
)
static member mpf_inp_str :
        rop : mpf_t *
        stream : ptr<FILE> *
        base : int -> size_t

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base.

Return Value

Type: size_t
Return the number of bytes read, or if an error occurred, return 0.
Remarks

The string is of the form "M@N" or, if the base is 10 or less, alternatively "MeN". "M" is the mantissa and "N’" is the exponent. The mantissa is always in the specified base. The exponent is either in the specified base or, if base is negative, in decimal. The decimal point expected is taken from the current locale, on systems providing localeconv.

The argument base may be in the ranges 2 to 36, or -36 to -2. Negative values are used to specify that the exponent is in decimal.

Unlike the corresponding mpz function, the base will not be determined from the leading characters of the string if base is 0. This is so that numbers like "0.23" are not interpreted as octal.

Examples
C#
VB
C++
F#
Copy
// Create and initialize op.
mpf_t op = new mpf_t();
gmp_lib.mpf_init(op);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(pathname, "0.123456e6");

// Read op from the temporary file, and assert that the number of bytes read is 6.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) == 10);
fclose(stream.Value.Value);

// Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpf_get_ui(op) == 123456U);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create and initialize op.
Dim op As New mpf_t()
gmp_lib.mpf_init(op)

' Write op to a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()
System.IO.File.WriteAllText(pathname, "0.123456e6")

' Read op from the temporary file, and assert that the number of bytes read is 6.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) = 10)
fclose(stream.Value.Value)

' Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpf_get_ui(op) = 123456UI)

' Delete temporary file.
System.IO.File.Delete(pathname)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_out_str


gmp_lib.mpf_integer_p Method

gmp_libmpf_integer_p Method
Return non-zero if op is an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_integer_p(
    mpf_t op
)
Public Shared Function mpf_integer_p (
    op As mpf_t
) As Integer
public:
static int mpf_integer_p(
    mpf_t^ op
)
static member mpf_integer_p :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return non-zero if op is an integer.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, 10);

// Assert that s is an integer.
Assert.IsTrue(gmp_lib.mpf_integer_p(x) != 0);

// Release unmanaged memory allocated for x.
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, 10)

' Assert that s is an integer.
Assert.IsTrue(gmp_lib.mpf_integer_p(x) <> 0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_mul Method

gmp_libmpf_mul Method
Set rop to op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_mul(
    mpf_t rop,
    mpf_t op1,
    mpf_t op2
)
Public Shared Sub mpf_mul (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mpf_t
)
public:
static void mpf_mul(
    mpf_t^ rop,
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_mul :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = x * y.
gmp_lib.mpf_mul(z, x, y);

// Assert that the value of z is -2100.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -2100.0);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x * y.
gmp_lib.mpf_mul(z, x, y)

' Assert that the value of z is -2100.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = -2100.0)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul_ui
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs
mpf_mul_2exp


gmp_lib.mpf_mul_2exp Method

gmp_libmpf_mul_2exp Method
Set rop to op1 * 2^op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_mul_2exp(
    mpf_t rop,
    mpf_t op1,
    mp_bitcnt_t op2
)
Public Shared Sub mpf_mul_2exp (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mp_bitcnt_t
)
public:
static void mpf_mul_2exp(
    mpf_t^ rop,
    mpf_t^ op1,
    mp_bitcnt_t op2
)
static member mpf_mul_2exp :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: Math.Gmp.Nativemp_bitcnt_t
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 100.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 100);

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

// Set z = x * 2^8.
gmp_lib.mpf_mul_2exp(z, x, 8U);

// Assert that the value of z is 25600.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 25600.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 100.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 100)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x * 2^8.
gmp_lib.mpf_mul_2exp(z, x, 8UI)

' Assert that the value of z is 25600.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 25600.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_mul_ui
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_mul_ui Method

gmp_libmpf_mul_ui Method
Set rop to op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_mul_ui(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_mul_ui (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_mul_ui(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_mul_ui :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: SystemUInt32
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = x * 210.
gmp_lib.mpf_mul_ui(z, x, 210U);

// Assert that the value of z is 2100.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2100.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x * 210.
gmp_lib.mpf_mul_ui(z, x, 210UI)

' Assert that the value of z is 2100.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 2100.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs
mpf_mul_2exp


gmp_lib.mpf_neg Method

gmp_libmpf_neg Method
Set rop to -op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_neg(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_neg (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_neg(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_neg :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = -x.
gmp_lib.mpf_neg(z, x);

// Assert that the value of z is -10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = -x.
gmp_lib.mpf_neg(z, x)

' Assert that the value of z is -10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = -10.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_abs


gmp_lib.mpf_out_str Method

gmp_libmpf_out_str Method
Print op to stream, as a string of digits.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpf_out_str(
    ptr<FILE> stream,
    int base,
    size_t n_digits,
    mpf_t op
)
Public Shared Function mpf_out_str (
    stream As ptr(Of FILE),
    base As Integer,
    n_digits As size_t,
    op As mpf_t
) As size_t
public:
static size_t mpf_out_str(
    ptr<FILE>^ stream,
    int base,
    size_t n_digits,
    mpf_t^ op
)
static member mpf_out_str :
        stream : ptr<FILE> *
        base : int *
        n_digits : size_t *
        op : mpf_t -> size_t

Parameters

stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base.
n_digits
Type: Math.Gmp.Nativesize_t
Maximum number fo digits to write.
op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: size_t
Return the number of bytes written, or if an error occurred, return 0.
Remarks

The mantissa is prefixed with an "0." and is in the given base, which may vary from 2 to 62 or from -2 to -36. An exponent is then printed, separated by an "e", or if the base is greater than 10 then by an "@". The exponent is always in decimal. The decimal point follows the current locale, on systems providing localeconv.

For base in the range 2..36, digits and lower-case letters are used; for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.

Up to n_digits will be printed from the mantissa, except that no more digits than are accurately representable by op will be printed. n_digits can be 0 to select that accurate maximum.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123456.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_ui(op, 123456U);

// Get a temporary file.
string pathname = System.IO.Path.GetTempFileName();

// Open temporary file for writing.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");

// Write op to temporary file, and assert that the number of bytes written is 10.
Assert.IsTrue(gmp_lib.mpf_out_str(stream, 10, 0, op) == 10);

// Close temporary file.
fclose(stream.Value.Value);

// Assert that the content of the temporary file is "123456".
string result = System.IO.File.ReadAllText(pathname);
Assert.IsTrue(result == "0.123456e6");

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpf_inp_str


gmp_lib.mpf_pow_ui Method

gmp_libmpf_pow_ui Method
Set rop to op1^op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_pow_ui(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_pow_ui (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_pow_ui(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_pow_ui :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: SystemUInt32
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = sqrt(x).
gmp_lib.mpf_pow_ui(z, x, 3U);

// Assert that the value of z is 1000.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 1000.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = sqrt(x).
gmp_lib.mpf_pow_ui(z, x, 3UI)

' Assert that the value of z is 1000.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 1000.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_neg
mpf_abs


gmp_lib.mpf_random2 Method

gmp_libmpf_random2 Method
Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_random2(
    mpf_t rop,
    mp_size_t max_size,
    mp_exp_t exp
)
Public Shared Sub mpf_random2 (
    rop As mpf_t,
    max_size As mp_size_t,
    exp As mp_exp_t
)
public:
static void mpf_random2(
    mpf_t^ rop,
    mp_size_t max_size,
    mp_exp_t exp
)
static member mpf_random2 :
        rop : mpf_t *
        max_size : mp_size_t *
        exp : mp_exp_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
exp
Type: Math.Gmp.Nativemp_exp_t
The range of the random exponent.
Remarks

The exponent of the number is in the interval -exp to exp (in limbs). This function is useful for testing functions and algorithms, since these kind of random numbers have proven to be more likely to trigger corner-case bugs. Negative random numbers are generated when max_size is negative.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpf_t rop = new mpf_t();
gmp_lib.mpf_init(rop);

// Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5].
gmp_lib.mpf_random2(rop, 10, 5);

// Free all memory occupied by rop.
gmp_lib.mpf_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpf_t()
gmp_lib.mpf_init(rop)

' Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5].
gmp_lib.mpf_random2(rop, 10, 5)

' Free all memory occupied by rop.
gmp_lib.mpf_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb


gmp_lib.mpf_reldiff Method

gmp_libmpf_reldiff Method
Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_reldiff(
    mpf_t rop,
    mpf_t op1,
    mpf_t op2
)
Public Shared Sub mpf_reldiff (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mpf_t
)
public:
static void mpf_reldiff(
    mpf_t^ rop,
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_reldiff :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand float.
op2
Type: Math.Gmp.Nativempf_t
The second operand float.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = |x - y| / x.
gmp_lib.mpf_reldiff(z, x, y);

// Assert that the value of z is 22.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 22.0);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = |x - y| / x.
gmp_lib.mpf_reldiff(z, x, y)

' Assert that the value of z is 22.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 22.0)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_z
mpf_cmp_d
mpf_cmp_ui
mpf_cmp_si
mpf_sgn


gmp_lib.mpf_set Method

gmp_libmpf_set Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_set (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_set(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_set :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(x, 128U);
gmp_lib.mpf_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init2(y, 128U);
gmp_lib.mpf_set_si(y, -210);

// Assign the value of y to x.
gmp_lib.mpf_set(x, y);

// Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, null);
' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init2(x, 128UI)
gmp_lib.mpf_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init2(y, 128UI)
gmp_lib.mpf_set_si(y, -210)

' Assign the value of y to x.
gmp_lib.mpf_set(x, y)

' Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -210.0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_ui
mpf_set_si
mpf_set_d
mpf_set_z
mpf_set_q
mpf_set_str
mpf_swap


gmp_lib.mpf_set_d Method

gmp_libmpf_set_d Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_d(
    mpf_t rop,
    double op
)
Public Shared Sub mpf_set_d (
    rop As mpf_t,
    op As Double
)
public:
static void mpf_set_d(
    mpf_t^ rop,
    double op
)
static member mpf_set_d :
        rop : mpf_t *
        op : float -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemDouble
The operand.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new floating-point number.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(x, 128U);

// Set x to -123.0.
gmp_lib.mpf_set_d(x, -123.0);

// Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);

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

' Set x to -123.0.
gmp_lib.mpf_set_d(x, -123.0)

' Assert that the value of x is -123.0.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_si
mpf_set_z
mpf_set_q
mpf_set_str
mpf_swap


gmp_lib.mpf_set_default_prec Method

gmp_libmpf_set_default_prec Method
Set the default precision 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
C#
VB
C++
F#
Copy
public static void mpf_set_default_prec(
    mp_bitcnt_t prec
)
Public Shared Sub mpf_set_default_prec (
    prec As mp_bitcnt_t
)
public:
static void mpf_set_default_prec(
    mp_bitcnt_t prec
)
static member mpf_set_default_prec :
        prec : mp_bitcnt_t -> unit

Parameters

prec
Type: Math.Gmp.Nativemp_bitcnt_t
The minimum precision in bits.
Remarks

All subsequent calls to mpf_init will use this precision, but previously initialized variables are unaffected.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128U);

// Assert that the value of x is 128 bits.
Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U);
' Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128UI)

' Assert that the value of x is 128 bits.
Assert.IsTrue(gmp_lib.mpf_get_default_prec() = 128UI)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec
mpf_set_prec_raw


gmp_lib.mpf_set_prec Method

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
C#
VB
C++
F#
Copy
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
C#
VB
C++
F#
Copy
// 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec_raw


gmp_lib.mpf_set_prec_raw Method

gmp_libmpf_set_prec_raw Method
Set the precision of rop to be at least prec bits, without changing the memory allocated.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_prec_raw(
    mpf_t rop,
    mp_bitcnt_t prec
)
Public Shared Sub mpf_set_prec_raw (
    rop As mpf_t,
    prec As mp_bitcnt_t
)
public:
static void mpf_set_prec_raw(
    mpf_t^ rop,
    mp_bitcnt_t prec
)
static member mpf_set_prec_raw :
        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

prec must be no more than the allocated precision for rop, that being the precision when rop was initialized, or in the most recent mpf_set_prec.

The value in rop is unchanged, and in particular if it had a higher precision than prec it will retain that higher precision. New values written to rop will use the new prec.

Before calling mpf_clear or the full mpf_set_prec, another mpf_set_prec_raw call must be made to restore rop to its original allocated precision. Failing to do so will have unpredictable results.

mpf_get_prec can be used before mpf_set_prec_raw to get the original allocated precision. After mpf_set_prec_raw it reflects the prec value set.

mpf_set_prec_raw is an efficient way to use an mpf_t variable at different precisions during a calculation, perhaps to gradually increase precision in an iteration, or just to use various different precisions for different purposes during a calculation.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128U);

// Create, initialize, and set a new rational y to 200 / 3.
mpq_t y = new mpq_t();
gmp_lib.mpq_init(y);
gmp_lib.mpq_set_ui(y, 200, 3U);

// Create, initialize, and set a new floating-point number x to y.
mpf_t x = new mpf_t();
gmp_lib.mpf_init(x);
gmp_lib.mpf_set_q(x, y);

Assert.IsTrue(x.ToString() == "0.6666666666666666666666666666666666666667e2");

// Change precision of x, and set its value to 10000 / 3.
gmp_lib.mpf_set_prec_raw(x, 8U);
gmp_lib.mpq_set_ui(y, 10000, 3U);
gmp_lib.mpf_set_q(x, y);

Assert.IsTrue(x.ToString() == "0.333333333333333333333e4");

// Restore precision of x.
gmp_lib.mpf_set_prec_raw(x, 128U);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.mpq_clear(y);
' Set default precision to 128 bits.
gmp_lib.mpf_set_default_prec(128UI)

' Create, initialize, and set a new rational y to 200 / 3.
Dim y As New mpq_t()
gmp_lib.mpq_init(y)
gmp_lib.mpq_set_ui(y, 200, 3UI)

' Create, initialize, and set a new floating-point number x to y.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)
gmp_lib.mpf_set_q(x, y)
Assert.IsTrue(x.ToString() = "0.6666666666666666666666666666666666666667e2")

' Change precision of x, and set its value to 10000 / 3.
gmp_lib.mpf_set_prec_raw(x, 8UI)
gmp_lib.mpq_set_ui(y, 10000, 3UI)
gmp_lib.mpf_set_q(x, y)
Assert.IsTrue(x.ToString() = "0.333333333333333333333e4")

' Restore precision of x.
gmp_lib.mpf_set_prec_raw(x, 128UI)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set_default_prec
mpf_get_default_prec
mpf_init
mpf_init2
mpf_inits
mpf_clear
mpf_clears
mpf_get_prec
mpf_set_prec


gmp_lib.mpf_set_q Method

gmp_libmpf_set_q Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_q(
    mpf_t rop,
    mpq_t op
)
Public Shared Sub mpf_set_q (
    rop As mpf_t,
    op As mpq_t
)
public:
static void mpf_set_q(
    mpf_t^ rop,
    mpq_t^ op
)
static member mpf_set_q :
        rop : mpf_t *
        op : mpq_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempq_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational y to 200 / 5.
mpq_t y = new mpq_t();
gmp_lib.mpq_init(y);
gmp_lib.mpq_set_ui(y, 200, 5U);

// Create, initialize, and set a new floating-point number x to y.
mpf_t x = new mpf_t();
gmp_lib.mpf_init(x);
gmp_lib.mpf_set_q(x, y);

// Assert that x is 40.
Assert.IsTrue(x.ToString() == "0.4e2");

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.mpq_clear(y);
' Create, initialize, and set a new rational y to 200 / 5.
Dim y As New mpq_t()
gmp_lib.mpq_init(y)
gmp_lib.mpq_set_ui(y, 200, 5UI)

' Create, initialize, and set a new floating-point number x to y.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)
gmp_lib.mpf_set_q(x, y)

' Assert that x is 40.
Assert.IsTrue(x.ToString() = "0.4e2")

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_si
mpf_set_d
mpf_set_z
mpf_set_str
mpf_swap


gmp_lib.mpf_set_si Method

gmp_libmpf_set_si Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_si(
    mpf_t rop,
    int op
)
Public Shared Sub mpf_set_si (
    rop As mpf_t,
    op As Integer
)
public:
static void mpf_set_si(
    mpf_t^ rop,
    int op
)
static member mpf_set_si :
        rop : mpf_t *
        op : int -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemInt32
The operand.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new floating-point number.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(x, 128U);

// Set x to -123.
gmp_lib.mpf_set_si(x, -123);

// Assert that the value of x is -123.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);

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

' Set x to -123.
gmp_lib.mpf_set_si(x, -123)

' Assert that the value of x is -123.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_d
mpf_set_z
mpf_set_q
mpf_set_str
mpf_swap


gmp_lib.mpf_set_str Method

gmp_libmpf_set_str Method
Set the value of rop from the string in str.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_set_str(
    mpf_t rop,
    char_ptr str,
    int base
)
Public Shared Function mpf_set_str (
    rop As mpf_t,
    str As char_ptr,
    base As Integer
) As Integer
public:
static int mpf_set_str(
    mpf_t^ rop,
    char_ptr str,
    int base
)
static member mpf_set_str :
        rop : mpf_t *
        str : char_ptr *
        base : int -> int

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
str
Type: Math.Gmp.Nativechar_ptr
The input string.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
This function returns 0 if the entire string is a valid number in base base. Otherwise it returns -1.
Remarks

The string is of the form "M@N" or, if the base is 10 or less, alternatively "MeN". "M" is the mantissa and "N" is the exponent. The mantissa is always in the specified base. The exponent is either in the specified base or, if base is negative, in decimal. The decimal point expected is taken from the current locale, on systems providing localeconv.

The argument base may be in the ranges 2 to 62, or -62 to -2. Negative values are used to specify that the exponent is in decimal.

For bases up to 36, case is ignored; upper-case and lower-case letters have the same value; for bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter represent 36..61.

Unlike the corresponding mpz function, the base will not be determined from the leading characters of the string if base is 0. This is so that numbers like "0.23" are not interpreted as octal.

White space is allowed in the string, and is simply ignored. [This is not really true; white-space is ignored in the beginning of the string and within the mantissa, but not in other places, such as after a minus sign or in the exponent. We are considering changing the definition of this function, making it fail when there is any white-space in the input, since that makes a lot of sense. Please tell us your opinion about this change. Do you really want it to accept "3 14" as meaning 314 as it does now?]

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new floating-point number x to 0.0234.
mpf_t x = new mpf_t();
gmp_lib.mpf_init(x);
char_ptr value = new char_ptr("234e-4");
gmp_lib.mpf_set_str(x, value, 10);

// Assert that x is 40.
Assert.IsTrue(x.ToString() == "0.234e-1");

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
' Create, initialize, and set a new floating-point number x to 0.0234.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)
Dim value As New char_ptr("234e-4")
gmp_lib.mpf_set_str(x, value, 10)

' Assert that x is 40.
Assert.IsTrue(x.ToString() = "0.234e-1")

' Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_si
mpf_set_d
mpf_set_z
mpf_set_q
mpf_swap


gmp_lib.mpf_set_ui Method

gmp_libmpf_set_ui Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_ui(
    mpf_t rop,
    uint op
)
Public Shared Sub mpf_set_ui (
    rop As mpf_t,
    op As UInteger
)
public:
static void mpf_set_ui(
    mpf_t^ rop,
    unsigned int op
)
static member mpf_set_ui :
        rop : mpf_t *
        op : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemUInt32
The operand.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new floating-point number.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(x, 128U);

// Set x to 100.
gmp_lib.mpf_set_ui(x, 100U);

// Assert that the value of x is 100.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0);

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

' Set x to 100.
gmp_lib.mpf_set_ui(x, 100UI)

' Assert that the value of x is 100.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = 100.0)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_si
mpf_set_d
mpf_set_z
mpf_set_q
mpf_set_str
mpf_swap


gmp_lib.mpf_set_z Method

gmp_libmpf_set_z Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_set_z(
    mpf_t rop,
    mpz_t op
)
Public Shared Sub mpf_set_z (
    rop As mpf_t,
    op As mpz_t
)
public:
static void mpf_set_z(
    mpf_t^ rop,
    mpz_t^ op
)
static member mpf_set_z :
        rop : mpf_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempz_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new integer y to 200.
mpz_t y = new mpz_t();
gmp_lib.mpz_init(y);
gmp_lib.mpz_set_ui(y, 200U);

// Create, initialize, and set a new floating-point number x to y.
mpf_t x = new mpf_t();
gmp_lib.mpf_init(x);
gmp_lib.mpf_set_z(x, y);

// Assert that x is 200.
Assert.IsTrue(x.ToString() == "0.2e3");

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.mpz_clear(y);
' Create, initialize, and set a new integer y to 200.
Dim y As New mpz_t()
gmp_lib.mpz_init(y)
gmp_lib.mpz_set_ui(y, 200UI)

' Create, initialize, and set a new floating-point number x to y.
Dim x As New mpf_t()
gmp_lib.mpf_init(x)
gmp_lib.mpf_set_z(x, y)

' Assert that x is 200.
Assert.IsTrue(x.ToString() = "0.2e3")

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_si
mpf_set_d
mpf_set_q
mpf_set_str
mpf_swap


gmp_lib.mpf_sgn Method

gmp_libmpf_sgn Method
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpf_sgn(
    mpf_t op
)
Public Shared Function mpf_sgn (
    op As mpf_t
) As Integer
public:
static int mpf_sgn(
    mpf_t^ op
)
static member mpf_sgn :
        op : mpf_t -> int

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Int32
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -10.
mpf_t op = new mpf_t();
gmp_lib.mpf_init_set_si(op, -10);

// Assert that the sign of op is -1.
Assert.IsTrue(gmp_lib.mpf_sgn(op) == -1);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
' Create, initialize, and set the value of op to -10.
Dim op As New mpf_t()
gmp_lib.mpf_init_set_si(op, -10)

' Assert that the sign of op is -1.
Assert.IsTrue(gmp_lib.mpf_sgn(op) = -1)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_cmp
mpf_cmp_z
mpf_cmp_d
mpf_cmp_ui
mpf_cmp_si
mpf_reldiff


gmp_lib.mpf_size Method

gmp_libmpf_size Method
Return the number of limbs currently in use.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpf_size(
    mpf_t op
)
Public Shared Function mpf_size (
    op As mpf_t
) As size_t
public:
static size_t mpf_size(
    mpf_t^ op
)
static member mpf_size :
        op : mpf_t -> size_t

Parameters

op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: size_t
The number of limbs currently in use.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x.
mpf_t x = "1.00000000000000000000001";

// Assert that the size of x is 1.
Assert.IsTrue(gmp_lib.mpf_size(x) == 4);

// Release unmanaged memory allocated for x.
gmp_lib.mpf_clear(x);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x.
Dim x As mpf_t = "1.00000000000000000000001"

' Assert that the size of x is 1.
Assert.IsTrue(gmp_lib.mpf_size(x) = 4)

' 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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_t


gmp_lib.mpf_sqrt Method

gmp_libmpf_sqrt Method
Set rop to the square root of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_sqrt(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_sqrt (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_sqrt(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_sqrt :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 100.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 100);

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

// Set z = sqrt(x).
gmp_lib.mpf_sqrt(z, x);

// Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 100.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 100)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = sqrt(x).
gmp_lib.mpf_sqrt(z, x)

' Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt_ui
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_sqrt_ui Method

gmp_libmpf_sqrt_ui Method
Set rop to the square root of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_sqrt_ui(
    mpf_t rop,
    uint op
)
Public Shared Sub mpf_sqrt_ui (
    rop As mpf_t,
    op As UInteger
)
public:
static void mpf_sqrt_ui(
    mpf_t^ rop,
    unsigned int op
)
static member mpf_sqrt_ui :
        rop : mpf_t *
        op : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: SystemUInt32
The operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

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

// Set z = sqrt(100).
gmp_lib.mpf_sqrt_ui(z, 100U);

// Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clear(z);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = sqrt(100).
gmp_lib.mpf_sqrt_ui(z, 100UI)

' Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_sub Method

gmp_libmpf_sub Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_sub(
    mpf_t rop,
    mpf_t op1,
    mpf_t op2
)
Public Shared Sub mpf_sub (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As mpf_t
)
public:
static void mpf_sub(
    mpf_t^ rop,
    mpf_t^ op1,
    mpf_t^ op2
)
static member mpf_sub :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = x - y.
gmp_lib.mpf_sub(z, x, y);

// Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()

gmp_lib.mpf_init_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x - y.
gmp_lib.mpf_sub(z, x, y)
///
' Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpf_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_ui_sub
mpf_sub_ui
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_sub_ui Method

gmp_libmpf_sub_ui Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_sub_ui(
    mpf_t rop,
    mpf_t op1,
    uint op2
)
Public Shared Sub mpf_sub_ui (
    rop As mpf_t,
    op1 As mpf_t,
    op2 As UInteger
)
public:
static void mpf_sub_ui(
    mpf_t^ rop,
    mpf_t^ op1,
    unsigned int op2
)
static member mpf_sub_ui :
        rop : mpf_t *
        op1 : mpf_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: Math.Gmp.Nativempf_t
The first operand.
op2
Type: SystemUInt32
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = x - 200.
gmp_lib.mpf_sub_ui(z, x, 200U);

// Assert that the value of z is -190.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == -190.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = x - 200.
gmp_lib.mpf_sub_ui(z, x, 200UI)

' Assert that the value of z is -190.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = -190.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_ui_sub
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_swap Method

gmp_libmpf_swap Method
Swap rop1 and rop2 efficiently.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_swap(
    mpf_t rop1,
    mpf_t rop2
)
Public Shared Sub mpf_swap (
    rop1 As mpf_t,
    rop2 As mpf_t
)
public:
static void mpf_swap(
    mpf_t^ rop1,
    mpf_t^ rop2
)
static member mpf_swap :
        rop1 : mpf_t *
        rop2 : mpf_t -> unit

Parameters

rop1
Type: Math.Gmp.Nativempf_t
The first result float.
rop2
Type: Math.Gmp.Nativempf_t
The second result float.
Remarks

Both the values and the precisions of the two variables are swapped.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init2(x, 128U);
gmp_lib.mpf_set_si(x, 10);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init2(y, 128U);
gmp_lib.mpf_set_si(y, -210);

// Swap the values of x and y.
gmp_lib.mpf_swap(x, y);

// Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0);

// Assert that the value of y is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, null);
' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init2(x, 128UI)
gmp_lib.mpf_set_si(x, 10)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init2(y, 128UI)
gmp_lib.mpf_set_si(y, -210)

' Swap the values of x and y.
gmp_lib.mpf_swap(x, y)

' Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpf_get_d(x) = -210.0)

' Assert that the value of y is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(y) = 10.0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_set
mpf_set_ui
mpf_set_si
mpf_set_d
mpf_set_z
mpf_set_q
mpf_set_str


gmp_lib.mpf_trunc Method

gmp_libmpf_trunc Method
Set rop to op rounded to the integer towards zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_trunc(
    mpf_t rop,
    mpf_t op
)
Public Shared Sub mpf_trunc (
    rop As mpf_t,
    op As mpf_t
)
public:
static void mpf_trunc(
    mpf_t^ rop,
    mpf_t^ op
)
static member mpf_trunc :
        rop : mpf_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op
Type: Math.Gmp.Nativempf_t
The operand float.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.4.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, 10.4);

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

// Set z = trunc(x).
gmp_lib.mpf_trunc(z, x);

// Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.4.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_d(x, 10.4)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = trunc(x).
gmp_lib.mpf_trunc(z, x)

' Assert that the value of z is 10.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_ceil
mpf_floor
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_urandomb
mpf_random2


gmp_lib.mpf_ui_div Method

gmp_libmpf_ui_div Method
Set rop to op1 / op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_ui_div(
    mpf_t rop,
    uint op1,
    mpf_t op2
)
Public Shared Sub mpf_ui_div (
    rop As mpf_t,
    op1 As UInteger,
    op2 As mpf_t
)
public:
static void mpf_ui_div(
    mpf_t^ rop,
    unsigned int op1,
    mpf_t^ op2
)
static member mpf_ui_div :
        rop : mpf_t *
        op1 : uint32 *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: SystemUInt32
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Remarks

Division is undefined if the divisor is zero, and passing a zero divisor to the divide functions will make it intentionally divide by zero. This lets the user handle arithmetic exceptions in division functions in the same manner as other arithmetic exceptions.

Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 10.
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_si(x, 10);

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

// Set z = 210 / x.
gmp_lib.mpf_ui_div(z, 210U, x);

// Assert that the value of z is 21.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 21.0);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number x to 10.
Dim x As New mpf_t()
gmp_lib.mpf_init_set_si(x, 10)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = 210 / x.
gmp_lib.mpf_ui_div(z, 210UI, x)

' Assert that the value of z is 21.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 21.0)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpf_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_mul
mpf_div
mpf_div_ui
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs
mpf_div_2exp


gmp_lib.mpf_ui_sub Method

gmp_libmpf_ui_sub Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_ui_sub(
    mpf_t rop,
    uint op1,
    mpf_t op2
)
Public Shared Sub mpf_ui_sub (
    rop As mpf_t,
    op1 As UInteger,
    op2 As mpf_t
)
public:
static void mpf_ui_sub(
    mpf_t^ rop,
    unsigned int op1,
    mpf_t^ op2
)
static member mpf_ui_sub :
        rop : mpf_t *
        op1 : uint32 *
        op2 : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
op1
Type: SystemUInt32
The first operand.
op2
Type: Math.Gmp.Nativempf_t
The second operand.
Examples
C#
VB
C++
F#
Copy
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init_set_si(y, -210);

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

// Set z = 10 - y.
gmp_lib.mpf_ui_sub(z, 10U, y);

// Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0);

// Release unmanaged memory allocated for y, and z.
gmp_lib.mpf_clears(y, z, null);
' Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64UI)

' Create, initialize, and set a new floating-point number y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init_set_si(y, -210)

' Create and initialize a new floating-point number z.
Dim z As New mpf_t()
gmp_lib.mpf_init(z)

' Set z = 10 - y.
gmp_lib.mpf_ui_sub(z, 10UI, y)

' Assert that the value of z is 220.
Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0)

' Release unmanaged memory allocated for y, and z.
gmp_lib.mpf_clears(y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpf_add
mpf_sub
mpf_sub_ui
mpf_mul
mpf_div
mpf_sqrt
mpf_pow_ui
mpf_neg
mpf_abs


gmp_lib.mpf_urandomb Method

gmp_libmpf_urandomb Method
Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpf_urandomb(
    mpf_t rop,
    gmp_randstate_t state,
    mp_bitcnt_t nbits
)
Public Shared Sub mpf_urandomb (
    rop As mpf_t,
    state As gmp_randstate_t,
    nbits As mp_bitcnt_t
)
public:
static void mpf_urandomb(
    mpf_t^ rop,
    gmp_randstate_t^ state,
    mp_bitcnt_t nbits
)
static member mpf_urandomb :
        rop : mpf_t *
        state : gmp_randstate_t *
        nbits : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
state
Type: Math.Gmp.Nativegmp_randstate_t
The random number generator state.
nbits
Type: Math.Gmp.Nativemp_bitcnt_t
Number of significant bits.
Remarks

The variable state must be initialized by calling one of the gmp_randinit functions (GNU MP - Random State Initialization) before invoking this function.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 100000U);

// Create, initialize, and set the value of rop to 0.
mpf_t rop = new mpf_t();
gmp_lib.mpf_init(rop);

// Generate a random integer in the range [0, 1) with 50 bits precision.
gmp_lib.mpf_urandomb(rop, state, 50);

// Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state);
gmp_lib.mpf_clear(rop);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpf_t()
gmp_lib.mpf_init(rop)

' Generate a random integer in the range [0, 1) with 50 bits precision.
gmp_lib.mpf_urandomb(rop, state, 50)

' Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state)
gmp_lib.mpf_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
Random State Initialization
mpf_ceil
mpf_floor
mpf_trunc
mpf_integer_p
mpf_fits_ulong_p
mpf_fits_slong_p
mpf_fits_uint_p
mpf_fits_sint_p
mpf_fits_ushort_p
mpf_fits_sshort_p
mpf_random2


gmp_lib.mpn_add Method

gmp_libmpn_add Method
Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_add(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t s1n,
    mp_ptr s2p,
    mp_size_t s2n
)
Public Shared Function mpn_add (
    rp As mp_ptr,
    s1p As mp_ptr,
    s1n As mp_size_t,
    s2p As mp_ptr,
    s2n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_add(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t s1n,
    mp_ptr^ s2p,
    mp_size_t s2n
)
static member mpn_add :
        rp : mp_ptr *
        s1p : mp_ptr *
        s1n : mp_size_t *
        s2p : mp_ptr *
        s2n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s1p.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
s2n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s2p.

Return Value

Type: mp_limb_t
Return carry, either 0 or 1.
Remarks

This function requires that s1n is greater than or equal to s2n.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = s1 + s2.
mp_limb_t carry = gmp_lib.mpn_add(rp, s1p, s1p.Size, s2p, s2p.Size);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = s1 + s2.
Dim carry As mp_limb_t = gmp_lib.mpn_add(rp, s1p, s1p.Size, s2p, s2p.Size)

' Assert result of operation.
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_add_1 Method

gmp_libmpn_add_1 Method
Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_add_1(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
Public Shared Function mpn_add_1 (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_add_1(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
static member mpn_add_1 :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s1p.
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
Return carry, either 0 or 1.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = s1 + 1.
mp_limb_t carry = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = s1 + 1.
 Dim carry As mp_limb_t = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1)

' Assert result of operation.
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_n
mpn_addmul_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_add_n Method

gmp_libmpn_add_n Method
Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_add_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_add_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_add_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_add_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s1p and s2p.

Return Value

Type: mp_limb_t
Return carry, either 0 or 1.
Remarks

This is the lowest-level function for addition. It is the preferred function for addition, since it is written in assembly for most CPUs. For addition of a variable to itself (i.e., s1p equals s2p) use mpn_lshift with a count of 1 for optimal speed.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = s1 + s2.
mp_limb_t carry = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H0})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = s1 + s2.
Dim carry As mp_limb_t = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size)

' Assert result of operation.

Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_addmul_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_addmul_1 Method

gmp_libmpn_addmul_1 Method
Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_addmul_1(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
Public Shared Function mpn_addmul_1 (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_addmul_1(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
static member mpn_addmul_1 :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s1p.
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
Return the most significant limb of the product, plus carry-out from the addition.
Remarks

{s1p, n} and {rp, n} are allowed to overlap provided rp ≤ s1p.

This is a low-level function that is a building block for general multiplication as well as other operations in GMP. It is written in assembly for most CPUs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 });
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp += s1 * 2.
mp_limb_t carry = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2);

// Assert result of operation.
Assert.IsTrue(carry == 0x02);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger() { &H2, &H0})
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp += s1 * 2.
Dim carry As mp_limb_t = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2)

' Assert result of operation.
Assert.IsTrue(carry = &H2)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_and_n Method

gmp_libmpn_and_n Method
Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_and_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_and_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_and_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_and_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });

// Set rp = s1 and s2.
gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H1, &H12345678})

' Set rp = s1 and s2.
gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_andn_n Method

gmp_libmpn_andn_n Method
Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_andn_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_andn_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_andn_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_andn_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 });

// Set rp = s1 and not s2.
gmp_lib.mpn_andn_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &Hedcba987UI})

' Set rp = s1 and not s2.
gmp_lib.mpn_andn_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_cmp Method

gmp_libmpn_cmp Method
Compare {s1p, n} and {s2p, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpn_cmp(
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_cmp (
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As Integer
public:
static int mpn_cmp(
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_cmp :
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> int

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in s1p and s2p.

Return Value

Type: Int32
Return a positive value if s1 > s2, 0 if they are equal, or a negative value if s1 < s2.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });

// Assert s1p > s2p.
Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0);

// Release unmanaged memory.
gmp_lib.free(s1p, s2p);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H0})

' Assert s1p > s2p.
Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0)

' Release unmanaged memory.
gmp_lib.free(s1p, s2p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_perfect_power_p
mpn_perfect_square_p
mpn_zero_p


gmp_lib.mpn_cnd_add_n Method

gmp_libmpn_cnd_add_n Method
If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_cnd_add_n(
    mp_limb_t cnd,
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_cnd_add_n (
    cnd As mp_limb_t,
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_cnd_add_n(
    mp_limb_t cnd,
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_cnd_add_n :
        cnd : mp_limb_t *
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

cnd
Type: Math.Gmp.Nativemp_limb_t
Conditonal value: non-zero for true, zero for false.
rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.

Return Value

Type: mp_limb_t
If cnd is non-zero, return carry, either 0 or 1, and if cnd is zero, return 0.
Remarks

This function does conditional addition. If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero. The functions is designed to have timing and memory access patterns depending only on size and location of the data areas, but independent of the condition cnd. Like for mpn_add_n, on most machines, the timing will also be independent of the actual limb values.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = s1 + s2.
mp_limb_t carry = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H0})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = s1 + s2.
Dim carry As mp_limb_t = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size)

' Assert result of operation.
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_cnd_sub_n Method

gmp_libmpn_cnd_sub_n Method
If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_cnd_sub_n(
    mp_limb_t cnd,
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_cnd_sub_n (
    cnd As mp_limb_t,
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_cnd_sub_n(
    mp_limb_t cnd,
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_cnd_sub_n :
        cnd : mp_limb_t *
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

cnd
Type: Math.Gmp.Nativemp_limb_t
Conditonal value: non-zero for true, zero for false.
rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.

Return Value

Type: mp_limb_t
If cnd is non-zero, return borrow, either 0 or 1, and if cnd is zero, return 0.
Remarks

This function does conditional addition. If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero. The functions is designed to have timing and memory access patterns depending only on size and location of the data areas, but independent of the condition cnd. Like for mpn_sub_n, on most machines, the timing will also be independent of the actual limb values.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });

// Set rp = s1 - s2.
mp_limb_t borrow = gmp_lib.mpn_cnd_sub_n(1, rp, s1p, s2p, rp.Size);

// Assert result of operation.
Assert.IsTrue(borrow == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H0})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})

' Set rp = s1 - s2.
Dim borrow As mp_limb_t = gmp_lib.mpn_cnd_sub_n(1, rp, s1p, s2p, rp.Size)

' Assert result of operation.
Assert.IsTrue(borrow = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_cnd_swap Method

gmp_libmpn_cnd_swap Method
If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_cnd_swap(
    mp_limb_t cnd,
    mp_ptr ap,
    mp_ptr bp,
    mp_size_t n
)
Public Shared Sub mpn_cnd_swap (
    cnd As mp_limb_t,
    ap As mp_ptr,
    bp As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_cnd_swap(
    mp_limb_t cnd,
    mp_ptr^ ap,
    mp_ptr^ bp,
    mp_size_t n
)
static member mpn_cnd_swap :
        cnd : mp_limb_t *
        ap : mp_ptr *
        bp : mp_ptr *
        n : mp_size_t -> unit

Parameters

cnd
Type: Math.Gmp.Nativemp_limb_t
Conditonal value: non-zero for true, zero for false.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
bp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and bp.
Remarks

Implemented using logical operations on the limbs, with the same memory accesses independent of the value of cnd.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr bp = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr a1p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr b1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });

// Exchange ab and bp.
gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size);

// Assert result of operation.
Assert.IsTrue(ap.SequenceEqual(a1p));
Assert.IsTrue(bp.SequenceEqual(b1p));

// Release unmanaged memory.
gmp_lib.free(ap, bp, a1p, b1p);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim bp As New mp_ptr(New UInteger() { &H1, &H0})
Dim a1p As New mp_ptr(New UInteger() { &H1, &H0})
Dim b1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})

' Exchange ab and bp.
gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size)

' Assert result of operation.
Assert.IsTrue(ap.SequenceEqual(a1p))
Assert.IsTrue(bp.SequenceEqual(b1p))

' Release unmanaged memory.
gmp_lib.free(ap, bp, a1p, b1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_com Method

gmp_libmpn_com Method
Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_com(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n
)
Public Shared Sub mpn_com (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_com(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_com :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The numbe rof limbs of rp>> and sp.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x0f0f0f0f, 0x0f0f0f0f });

// Set rp = not(sp).
gmp_lib.mpn_com(rp, sp, sp.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f, &Hf0f0f0f})

' Set rp = not(sp).
gmp_lib.mpn_com(rp, sp, sp.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_copyd Method

gmp_libmpn_copyd Method
Copy from {s1p, n} to {rp, n}, decreasingly.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_copyd(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n
)
Public Shared Sub mpn_copyd (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_copyd(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n
)
static member mpn_copyd :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });

// Set rp = sp.
gmp_lib.mpn_copyd(rp, sp, sp.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI})

' Set rp = sp.
gmp_lib.mpn_copyd(rp, sp, sp.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_copyi
mpn_zero


gmp_lib.mpn_copyi Method

gmp_libmpn_copyi Method
Copy from {s1p, n} to {rp, n}, increasingly.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_copyi(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n
)
Public Shared Sub mpn_copyi (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_copyi(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n
)
static member mpn_copyi :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });

// Set rp = sp.
gmp_lib.mpn_copyi(rp, sp, sp.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI})

' Set rp = sp.
gmp_lib.mpn_copyi(rp, sp, sp.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_copyd
mpn_zero


gmp_lib.mpn_divexact_1 Method

gmp_libmpn_divexact_1 Method
Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_divexact_1(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n,
    mp_limb_t d
)
Public Shared Sub mpn_divexact_1 (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t,
    d As mp_limb_t
)
public:
static void mpn_divexact_1(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n,
    mp_limb_t d
)
static member mpn_divexact_1 :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t *
        d : mp_limb_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in sp and rp.
d
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.
Remarks

If d doesn’t divide exactly, the value written to {rp, n} is undefined. The areas at rp and sp have to be identical or completely separate, not partially overlapping.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 });

// Set rp = sp / 3.
gmp_lib.mpn_divexact_1(rp, sp, sp.Size, 0x3);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H55555555, &H5555})

' Set rp = sp / 3.
gmp_lib.mpn_divexact_1(rp, sp, sp.Size, &H3)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_divexact_by3 Method

gmp_libmpn_divexact_by3 Method
Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_divexact_by3(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n
)
Public Shared Function mpn_divexact_by3 (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_divexact_by3(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_divexact_by3 :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in sp.

Return Value

Type: mp_limb_t
If 3 divides exactly, the return value is zero and the result is the quotient. If not, the return value is non-zero and the result won’t be anything useful.
Remarks

mpn_divexact_by3c takes an initial carry parameter, which can be the return value from a previous call, so a large calculation can be done piece by piece from low to high. mpn_divexact_by3 is simply a macro calling mpn_divexact_by3c with a 0 carry parameter.

These routines use a multiply-by-inverse and will be faster than mpn_divrem_1 on CPUs with fast multiplication but slow division.

The source a, result q, size n, initial carry i, and return value c satisfy c * b^n + a - i = 3 * q, where b = 2^mp_bits_per_limb. The return c is always 0, 1 or 2, and the initial carry i must also be 0, 1 or 2 (these are both borrows really). When c = 0 clearly q = (a - i) / 3. When c != 0, the remainder (a - i) mod 3 is given by 3 - c, because b ≡ 1 mod 3 (when mp_bits_per_limb is even, which is always so currently).

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 });

// Set rp = sp / 3.
mp_limb_t remainder = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size);

// Assert result of operation.
Assert.IsTrue(remainder == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H55555555, &H5555})

' Set rp = sp / 3.
Dim remainder As mp_limb_t = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size)

' Assert result of operation.

Assert.IsTrue(remainder = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_divexact_by3c Method

gmp_libmpn_divexact_by3c Method
Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_divexact_by3c(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n,
    mp_limb_t carry
)
Public Shared Function mpn_divexact_by3c (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t,
    carry As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_divexact_by3c(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n,
    mp_limb_t carry
)
static member mpn_divexact_by3c :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t *
        carry : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in sp.
carry
Type: Math.Gmp.Nativemp_limb_t
The initial carry.

Return Value

Type: mp_limb_t
If 3 divides exactly, the return value is zero and the result is the quotient. If not, the return value is non-zero and the result won’t be anything useful.
Remarks

mpn_divexact_by3c takes an initial carry parameter, which can be the return value from a previous call, so a large calculation can be done piece by piece from low to high. mpn_divexact_by3 is simply a macro calling mpn_divexact_by3c with a 0 carry parameter.

These routines use a multiply-by-inverse and will be faster than mpn_divrem_1 on CPUs with fast multiplication but slow division.

The source a, result q, size n, initial carry i, and return value c satisfy c * b^n + a - i = 3 * q, where b = 2^mp_bits_per_limb. The return c is always 0, 1 or 2, and the initial carry i must also be 0, 1 or 2 (these are both borrows really). When c = 0 clearly q = (a - i) / 3. When c != 0, the remainder (a - i) mod 3 is given by 3 - c, because b ≡ 1 mod 3 (when mp_bits_per_limb is even, which is always so currently).

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xaaaaaaaa, 0x5555aaaa });

// Set rp = sp / 3.
mp_limb_t remainder = gmp_lib.mpn_divexact_by3c(rp, sp, sp.Size, 1);

// Assert result of operation.
Assert.IsTrue(remainder == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HaaaaaaaaUI, &H5555aaaa})

' Set rp = sp / 3.
Dim remainder As mp_limb_t = gmp_lib.mpn_divexact_by3c(rp, sp, sp.Size, 1)

' Assert result of operation.
Assert.IsTrue(remainder = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_divmod_1 Method

gmp_libmpn_divmod_1 Method
Divide {s2p, s2n} by s3limb, and write the quotient at r1p.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_divmod_1(
    mp_ptr r1p,
    mp_ptr s2p,
    mp_size_t s2n,
    mp_limb_t s3limb
)
Public Shared Function mpn_divmod_1 (
    r1p As mp_ptr,
    s2p As mp_ptr,
    s2n As mp_size_t,
    s3limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_divmod_1(
    mp_ptr^ r1p,
    mp_ptr^ s2p,
    mp_size_t s2n,
    mp_limb_t s3limb
)
static member mpn_divmod_1 :
        r1p : mp_ptr *
        s2p : mp_ptr *
        s2n : mp_size_t *
        s3limb : mp_limb_t -> mp_limb_t

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
s2p
Type: Math.Gmp.Nativemp_ptr
s2n
Type: Math.Gmp.Nativemp_size_t
s3limb
Type: Math.Gmp.Nativemp_limb_t

Return Value

Type: mp_limb_t
Return the remainder.
Remarks

The integer quotient is written to {r1p, s2n}. s2n can be zero.

mpn_divmod_1 exists for upward source compatibility and is simply a macro calling mpn_divrem_1 with a qxn of 0.

The areas at r1p and s2p have to be identical or completely separate, not partially overlapping.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr r1p = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 });

// Set r1p = s2p / 19.
mp_limb_t remainder = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, 0x13);

// Assert result of operation.
Assert.IsTrue(remainder == 10);
Assert.IsTrue(r1p.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(r1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s2p As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim r1p As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H435e50d7, &Hd79})

' Set r1p = s2p / 19.
Dim remainder As mp_limb_t = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, &H13)

' Assert result of operation.
Assert.IsTrue(remainder = 10)
Assert.IsTrue(r1p.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(r1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_divrem_1 Method

gmp_libmpn_divrem_1 Method
Divide {s2p, s2n} by s3limb, and write the quotient at r1p.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_divrem_1(
    mp_ptr r1p,
    mp_size_t qxn,
    mp_ptr s2p,
    mp_size_t s2n,
    mp_limb_t s3limb
)
Public Shared Function mpn_divrem_1 (
    r1p As mp_ptr,
    qxn As mp_size_t,
    s2p As mp_ptr,
    s2n As mp_size_t,
    s3limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_divrem_1(
    mp_ptr^ r1p,
    mp_size_t qxn,
    mp_ptr^ s2p,
    mp_size_t s2n,
    mp_limb_t s3limb
)
static member mpn_divrem_1 :
        r1p : mp_ptr *
        qxn : mp_size_t *
        s2p : mp_ptr *
        s2n : mp_size_t *
        s3limb : mp_limb_t -> mp_limb_t

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
qxn
Type: Math.Gmp.Nativemp_size_t
s2p
Type: Math.Gmp.Nativemp_ptr
s2n
Type: Math.Gmp.Nativemp_size_t
s3limb
Type: Math.Gmp.Nativemp_limb_t

Return Value

Type: mp_limb_t
Return the remainder.
Remarks

The integer quotient is written to {r1p + qxn, s2n} and in addition qxn fraction limbs are developed and written to {r1p, qxn}. Either or both s2n and qxn can be zero. For most usages, qxn will be zero.

mpn_divmod_1 exists for upward source compatibility and is simply a macro calling mpn_divrem_1 with a qxn of 0.

The areas at r1p and s2p have to be identical or completely separate, not partially overlapping.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr r1p = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 });

// Set r1p = s2p / 19.
mp_limb_t remainder = gmp_lib.mpn_divrem_1(r1p, 0, s2p, s2p.Size, 0x13);

// Assert result of operation.
Assert.IsTrue(remainder == 10);
Assert.IsTrue(r1p.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(r1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s2p As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim r1p As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H435e50d7, &Hd79})

' Set r1p = s2p / 19.
Dim remainder As mp_limb_t = gmp_lib.mpn_divrem_1(r1p, 0, s2p, s2p.Size, &H13)

' Assert result of operation.
Assert.IsTrue(remainder = 10)
Assert.IsTrue(r1p.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(r1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_gcd Method

gmp_libmpn_gcd Method
Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_gcd(
    mp_ptr rp,
    mp_ptr xp,
    mp_size_t xn,
    mp_ptr yp,
    mp_size_t yn
)
Public Shared Function mpn_gcd (
    rp As mp_ptr,
    xp As mp_ptr,
    xn As mp_size_t,
    yp As mp_ptr,
    yn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_gcd(
    mp_ptr^ rp,
    mp_ptr^ xp,
    mp_size_t xn,
    mp_ptr^ yp,
    mp_size_t yn
)
static member mpn_gcd :
        rp : mp_ptr *
        xp : mp_ptr *
        xn : mp_size_t *
        yp : mp_ptr *
        yn : mp_size_t -> mp_size_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
xp
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
xn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of xp.
yp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
yn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of yp.

Return Value

Type: mp_size_t
The result can be up to yn limbs, the return value is the actual number produced; i.e. the number of limbs of rp.
Remarks

Both source operands are destroyed.

It is required that xn ≥ yn > 0, and the most significant limb of {yp, yn} must be non-zero. No overlap is permitted between {xp, xn} and {yp, yn}.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr xp = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });
mp_ptr yp = new mp_ptr(new uint[] { 0xc2d24d55, 0x00000007 });
mp_ptr rp = new mp_ptr(yp.Size);
mp_ptr result = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });

// Set rp = gcd(xp, yp).
mp_size_t size = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size);

// Assert result of operation.
Assert.IsTrue(size == result.Size);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, xp, yp, result);
' Create multi-precision operands, and expected result.
Dim xp As New mp_ptr(New UInteger() { &H964619c7UI, &H2})
Dim yp As New mp_ptr(New UInteger() { &Hc2d24d55UI, &H7})
Dim rp As New mp_ptr(yp.Size)
Dim result As New mp_ptr(New UInteger() { &H964619c7UI, &H2})

' Set rp = gcd(xp, yp).
Dim size As mp_size_t = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size)

' Assert result of operation.
Assert.IsTrue(size = result.Size)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, xp, yp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_gcd_1
O:Math.Gmp.Native.gmp_lib.mpn_gcdext


gmp_lib.mpn_gcd_1 Method

gmp_libmpn_gcd_1 Method
Return the greatest common divisor of {xp, xn} and ylimb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_gcd_1(
    mp_ptr xp,
    mp_size_t xn,
    mp_limb_t ylimb
)
Public Shared Function mpn_gcd_1 (
    xp As mp_ptr,
    xn As mp_size_t,
    ylimb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_gcd_1(
    mp_ptr^ xp,
    mp_size_t xn,
    mp_limb_t ylimb
)
static member mpn_gcd_1 :
        xp : mp_ptr *
        xn : mp_size_t *
        ylimb : mp_limb_t -> mp_limb_t

Parameters

xp
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
xn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of xp.
ylimb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
The greatest common divisor of {xp, xn} and ylimb.
Remarks

Both operands must be non-zero.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr xp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 });

// Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) == 1073741824);

// Release unmanaged memory.
gmp_lib.free(xp);
' Create multi-precision operand.
Dim xp As New mp_ptr(New UInteger() { &H0, &H1})

' Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) = 1073741824)

' Release unmanaged memory.
gmp_lib.free(xp)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_gcd
O:Math.Gmp.Native.gmp_lib.mpn_gcdext


gmp_lib.mpn_gcdext Method

gmp_libmpn_gcdext Method
Overload List
Name | Description
mpn_gcdext(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
mpn_gcdext(mp_ptr, mp_ptr, ptrmp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t) | Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpn_gcdext Method (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)

gmp_libmpn_gcdext Method (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)
Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_gcdext(
    mp_ptr gp,
    mp_ptr sp,
    ref mp_size_t sn,
    mp_ptr up,
    mp_size_t un,
    mp_ptr vp,
    mp_size_t vn
)
Public Shared Function mpn_gcdext (
    gp As mp_ptr,
    sp As mp_ptr,
    ByRef sn As mp_size_t,
    up As mp_ptr,
    un As mp_size_t,
    vp As mp_ptr,
    vn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_gcdext(
    mp_ptr^ gp,
    mp_ptr^ sp,
    mp_size_t% sn,
    mp_ptr^ up,
    mp_size_t un,
    mp_ptr^ vp,
    mp_size_t vn
)
static member mpn_gcdext :
        gp : mp_ptr *
        sp : mp_ptr *
        sn : mp_size_t byref *
        up : mp_ptr *
        un : mp_size_t *
        vp : mp_ptr *
        vn : mp_size_t -> mp_size_t

Parameters

gp
Type: Math.Gmp.Nativemp_ptr
The fisrt result operand.
sp
Type: Math.Gmp.Nativemp_ptr
The second result operand.
sn
Type: Math.Gmp.Nativemp_size_t
Pointer to the number of limbs of sp.
up
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
un
Type: Math.Gmp.Nativemp_size_t
The number of limbs of up.
vp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
vn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of vp.

Return Value

Type: mp_size_t
The number of limbs of gp.
Remarks

Let U be defined by {up, un} and let V be defined by {vp, vn}.

The second cofactor T is not computed but can easily be obtained from (G - U * S) / V (the division will be exact). It is required that un ≥ vn > 0, and the most significant limb of {vp, vn} must be non-zero.

Store G at gp and let the return value define its limb count. Store S at sp and let | sn.Value | define its limb count. S can be negative; when this happens sn.Value will be negative. The area at gp should have room for vn limbs and the area at sp should have room for vn + 1 limbs.

Both source operands are destroyed.

Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly. Earlier as well as later GMP releases define S as described here. GMP releases before GMP 4.3.0 required additional space for both input and output areas. More precisely, the areas {up, un + 1} and {vp, vn + 1} were destroyed (i.e. the operands plus an extra limb past the end of each), and the areas pointed to by gp and sp should each have room for un + 1 limbs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr up = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
mp_ptr vp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 });
mp_ptr gp = new mp_ptr(new uint[vp.Size * (IntPtr.Size / 4)]);
mp_ptr sp = new mp_ptr(new uint[(vp.Size + 1) * (IntPtr.Size / 4)]);
mp_ptr result = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
mp_ptr cofactor = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0x00000000 });

// Set gp = gcd(up, vp).
mp_size_t sn = 0;
mp_size_t size = gmp_lib.mpn_gcdext(gp, sp, ref sn, up, up.Size, vp, vp.Size);

// Assert result.
Assert.IsTrue(size == 1);
Assert.IsTrue(gp.SequenceEqual(result));
Assert.IsTrue(sn == 1);
Assert.IsTrue(sp.SequenceEqual(cofactor));

// Release unmanaged memory.
gmp_lib.free(gp, up, vp, sp, result, cofactor);
' Create multi-precision operands, and expected result.
Dim up As New mp_ptr(New UInteger() { &H40000000, &H0})
Dim vp As New mp_ptr(New UInteger() { &H0, &H1})
Dim gp As New mp_ptr(New UInteger(vp.Size* (IntPtr.Size / 4) - 1) {})
Dim sp As New mp_ptr(New UInteger((vp.Size + 1) * (IntPtr.Size / 4) - 1) {})
Dim result As New mp_ptr(New UInteger() { &H40000000, &H0})
Dim cofactor As New mp_ptr(New UInteger() { &H1, &H0, &H0})

' Set gp = gcd(up, vp).
Dim sn As mp_size_t = 0
Dim size As mp_size_t = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size)

' Assert result.
Assert.IsTrue(size = 1)
Assert.IsTrue(gp.SequenceEqual(result))
Assert.IsTrue(sn = 1)
Assert.IsTrue(sp.SequenceEqual(cofactor))

' Release unmanaged memory.
gmp_lib.free(gp, up, vp, sp, result, cofactor)

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

Reference

gmp_lib Class
mpn_gcdext Overload
Math.Gmp.Native Namespace
mpn_gcd
mpn_gcd_1


gmp_lib.mpn_gcdext Method (mp_ptr, mp_ptr, ptr(mp_size_t), mp_ptr, mp_size_t, mp_ptr, mp_size_t)

gmp_libmpn_gcdext Method (mp_ptr, mp_ptr, ptrmp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)
Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_gcdext(
    mp_ptr gp,
    mp_ptr sp,
    ptr<mp_size_t> sn,
    mp_ptr up,
    mp_size_t un,
    mp_ptr vp,
    mp_size_t vn
)
Public Shared Function mpn_gcdext (
    gp As mp_ptr,
    sp As mp_ptr,
    sn As ptr(Of mp_size_t),
    up As mp_ptr,
    un As mp_size_t,
    vp As mp_ptr,
    vn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_gcdext(
    mp_ptr^ gp,
    mp_ptr^ sp,
    ptr<mp_size_t>^ sn,
    mp_ptr^ up,
    mp_size_t un,
    mp_ptr^ vp,
    mp_size_t vn
)
static member mpn_gcdext :
        gp : mp_ptr *
        sp : mp_ptr *
        sn : ptr<mp_size_t> *
        up : mp_ptr *
        un : mp_size_t *
        vp : mp_ptr *
        vn : mp_size_t -> mp_size_t

Parameters

gp
Type: Math.Gmp.Nativemp_ptr
The fisrt result operand.
sp
Type: Math.Gmp.Nativemp_ptr
The second result operand.
sn
Type: Math.Gmp.Nativeptr mp_size_t
Pointer to the number of limbs of sp.
up
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
un
Type: Math.Gmp.Nativemp_size_t
The number of limbs of up.
vp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
vn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of vp.

Return Value

Type: mp_size_t
The number of limbs of gp.
Remarks

Let U be defined by {up, un} and let V be defined by {vp, vn}.

The second cofactor T is not computed but can easily be obtained from (G - U * S) / V (the division will be exact). It is required that un ≥ vn > 0, and the most significant limb of {vp, vn} must be non-zero.

Store G at gp and let the return value define its limb count. Store S at sp and let | sn.Value | define its limb count. S can be negative; when this happens sn.Value will be negative. The area at gp should have room for vn limbs and the area at sp should have room for vn + 1 limbs.

Both source operands are destroyed.

Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly. Earlier as well as later GMP releases define S as described here. GMP releases before GMP 4.3.0 required additional space for both input and output areas. More precisely, the areas {up, un + 1} and {vp, vn + 1} were destroyed (i.e. the operands plus an extra limb past the end of each), and the areas pointed to by gp and sp should each have room for un + 1 limbs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr up = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
mp_ptr vp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 });
mp_ptr gp = new mp_ptr(new uint[vp.Size * (IntPtr.Size / 4)]);
mp_ptr sp = new mp_ptr(new uint[(vp.Size + 1) * (IntPtr.Size / 4)]);
mp_ptr result = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
mp_ptr cofactor = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0x00000000 });

// Set gp = gcd(up, vp).
ptr<mp_size_t> sn = new ptr<mp_size_t>(0);
mp_size_t size = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size);

// Assert result.
Assert.IsTrue(size == 1);
Assert.IsTrue(gp.SequenceEqual(result));
Assert.IsTrue(sn.Value == 1);
Assert.IsTrue(sp.SequenceEqual(cofactor));

// Release unmanaged memory.
gmp_lib.free(gp, up, vp, sp, result, cofactor);
' Create multi-precision operands, and expected result.
Dim up As New mp_ptr(New UInteger() { &H40000000, &H0})
Dim vp As New mp_ptr(New UInteger() { &H0, &H1})
Dim gp As New mp_ptr(New UInteger(vp.Size* (IntPtr.Size / 4) - 1) {})
Dim sp As New mp_ptr(New UInteger((vp.Size + 1) * (IntPtr.Size / 4) - 1) {})
Dim result As New mp_ptr(New UInteger() { &H40000000, &H0})
Dim cofactor As New mp_ptr(New UInteger() { &H1, &H0, &H0})

' Set gp = gcd(up, vp).
Dim sn As New ptr(Of mp_size_t)(0)
Dim size As mp_size_t = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size)

' Assert result.
Assert.IsTrue(size = 1)
Assert.IsTrue(gp.SequenceEqual(result))
Assert.IsTrue(sn.Value = 1)
Assert.IsTrue(sp.SequenceEqual(cofactor))

' Release unmanaged memory.
gmp_lib.free(gp, up, vp, sp, result, cofactor)

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

Reference

gmp_lib Class
mpn_gcdext Overload
Math.Gmp.Native Namespace
mpn_gcd
mpn_gcd_1


gmp_lib.mpn_get_str Method

gmp_libmpn_get_str Method
Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpn_get_str(
    char_ptr str,
    int base,
    mp_ptr s1p,
    mp_size_t s1n
)
Public Shared Function mpn_get_str (
    str As char_ptr,
    base As Integer,
    s1p As mp_ptr,
    s1n As mp_size_t
) As size_t
public:
static size_t mpn_get_str(
    char_ptr str,
    int base,
    mp_ptr^ s1p,
    mp_size_t s1n
)
static member mpn_get_str :
        str : char_ptr *
        base : int *
        s1p : mp_ptr *
        s1n : mp_size_t -> size_t

Parameters

str
Type: Math.Gmp.Nativechar_ptr
The result string.
base
Type: SystemInt32
The base.
s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
s1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.

Return Value

Type: size_t
The number of characters produced at str.
Remarks

There may be leading zeros in the string. The string is not in ASCII; to convert it to printable format, add the ASCII codes for "0" or "A", depending on the base and range. base can vary from 2 to 256.

The most significant limb of the input {s1p, s1n} must be non-zero. The input {s1p, s1n} is clobbered, except when base is a power of 2, in which case it’s unchanged.

The area at str has to have space for the largest possible number represented by a s1n long limb array, plus one extra character.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands.
mp_ptr s1p = new mp_ptr(new uint[] { 0x00000001, 0x00000001 });
char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx");

// Convert s1p to hex string.
size_t count = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size);

// Copy out str to bytes.
byte[] s = new byte[count];
Marshal.Copy(str.ToIntPtr(), s, 0, (int)count);

// Assert the non-ASCII, hex representation of s1p.
Assert.IsTrue(s.SequenceEqual(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 }));

// Release unmanaged memory.
gmp_lib.free(s1p);
gmp_lib.free(str);
' Create multi-precision operands.
Dim s1p As New mp_ptr(New UInteger() { &H1, &H1})
Dim str As New char_ptr("xxxxxxxxxxxxxxxxx")

' Convert s1p to hex string.
Dim count As size_t = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size)

' Copy out str to bytes.
Dim s As Byte() = New Byte(count - 1) { }
Marshal.Copy(str.ToIntPtr(), s, 0, CInt(count))

' Assert the non-ASCII, hex representation of s1p.
Assert.IsTrue(s.SequenceEqual(New Byte() { 1, 0, 0, 0, 0, 0, 0, 0, 1}))

' Release unmanaged memory.
gmp_lib.free(s1p)
gmp_lib.free(str)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_set_str
mpn_sizeinbase


gmp_lib.mpn_hamdist Method

gmp_libmpn_hamdist Method
Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpn_hamdist(
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_hamdist (
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpn_hamdist(
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_hamdist :
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> mp_bitcnt_t

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.

Return Value

Type: mp_bitcnt_t
The hamming distance between {s1p, n} and {s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0xffffffff });

// Assert hamming distance.
Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) == 31);

// Release unmanaged memory.
gmp_lib.free(s1p, s2p);
' Create multi-precision operands.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &HffffffffUI})

' Assert hamming distance.
Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) = 31)

' Release unmanaged memory.
gmp_lib.free(s1p, s2p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_lshift
mpn_popcount
mpn_rshift
mpn_scan0
mpn_scan1


gmp_lib.mpn_ior_n Method

gmp_libmpn_ior_n Method
Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_ior_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_ior_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_ior_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_ior_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });

// Set rp = s1 or s2.
gmp_lib.mpn_ior_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})

' Set rp = s1 or s2.
gmp_lib.mpn_ior_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_iorn_n Method

gmp_libmpn_iorn_n Method
Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_iorn_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_iorn_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_iorn_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_iorn_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });

// Set rp = s1 or not s2.
gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})

' Set rp = s1 or not s2.
gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_nand_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_lshift Method

gmp_libmpn_lshift Method
Shift {sp, n} left by count bits, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_lshift(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n,
    uint count
)
Public Shared Function mpn_lshift (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t,
    count As UInteger
) As mp_limb_t
public:
static mp_limb_t mpn_lshift(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n,
    unsigned int count
)
static member mpn_lshift :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t *
        count : uint32 -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of sp.
count
Type: SystemUInt32
The number of bits ot shift.

Return Value

Type: mp_limb_t
The bits shifted out at the left are returned in the least significant count bits of the return value (the rest of the return value is zero).
Remarks

count must be in the range 1 to mp_bits_per_limb - 1. The regions {sp, n} and {rp, n} may overlap, provided rp ≥ sp.

This function is written in assembly for most CPUs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffc, 0xffffffff });

// Set rp = sp << 1.
mp_limb_t bits = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1);

// Assert result of operation.
Assert.IsTrue(bits == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffcUI, &HffffffffUI})

' Set rp = sp << 1.
Dim bits As mp_limb_t = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1)

' Assert result of operation.
Assert.IsTrue(bits = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_hamdist
mpn_popcount
mpn_rshift
mpn_scan0
mpn_scan1


gmp_lib.mpn_mod_1 Method

gmp_libmpn_mod_1 Method
Divide {s1p, s1n} by s2limb, and return the remainder.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_mod_1(
    mp_ptr s1p,
    mp_size_t s1n,
    mp_limb_t s2limb
)
Public Shared Function mpn_mod_1 (
    s1p As mp_ptr,
    s1n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_mod_1(
    mp_ptr^ s1p,
    mp_size_t s1n,
    mp_limb_t s2limb
)
static member mpn_mod_1 :
        s1p : mp_ptr *
        s1n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
The remainder.
Remarks

s1n can be zero.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0xfffffffe, 0x0000ffff });

// Assert s1p mod 3 is 2.
Assert.IsTrue(gmp_lib.mpn_mod_1(s1p, s1p.Size, 3) == 2);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &HfffffffeUI, &Hffff})

' Assert s1p mod 3 is 2.
Assert.IsTrue(gmp_lib.mpn_mod_1(s1p, s1p.Size, 3) = 2)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_mul Method

gmp_libmpn_mul Method
Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_mul(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t s1n,
    mp_ptr s2p,
    mp_size_t s2n
)
Public Shared Function mpn_mul (
    rp As mp_ptr,
    s1p As mp_ptr,
    s1n As mp_size_t,
    s2p As mp_ptr,
    s2n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_mul(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t s1n,
    mp_ptr^ s2p,
    mp_size_t s2n
)
static member mpn_mul :
        rp : mp_ptr *
        s1p : mp_ptr *
        s1n : mp_size_t *
        s2p : mp_ptr *
        s2n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
s2p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s2p.

Return Value

Type: mp_limb_t
Return the most significant limb of the result.
Remarks

The destination has to have space for s1n + s2n limbs, even if the product’s most significant limb is zero. No overlap is permitted between the destination and either source.

This function requires that s1n is greater than or equal to s2n.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002 });
mp_ptr rp = new mp_ptr(new uint[3]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 });

// Set rp = s1 * s2.
gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H2})
Dim rp As New mp_ptr(New UInteger(2) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1})

' Set rp = s1 * s2.
gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_mul_1 Method

gmp_libmpn_mul_1 Method
Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_mul_1(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
Public Shared Function mpn_mul_1 (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_mul_1(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
static member mpn_mul_1 :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
Return the most significant limb of the product.
Remarks

{s1p, n} and {rp, n} are allowed to overlap provided rp ≤ s1p.

This is a low-level function that is a building block for general multiplication as well as other operations in GMP. It is written in assembly for most CPUs.

Don’t call this function if s2limb is a power of 2; use mpn_lshift with a count equal to the logarithm of s2limb instead, for optimal speed.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });

// Set rp = s1 * 2.
mp_limb_t carry = gmp_lib.mpn_mul_1(rp, s1p, s1p.Size, 2);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})

' Set rp = s1 * 2.
Dim carry As mp_limb_t = gmp_lib.mpn_mul_1(rp, s1p, s1p.Size, 2)

' Assert result of operation.
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_mul_n Method

gmp_libmpn_mul_n Method
Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_mul_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_mul_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_mul_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_mul_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Remarks

The destination has to have space for 2 * n limbs, even if the product’s most significant limb is zero. No overlap is permitted between the destination and either source.

If the two input operands are the same, use mpn_sqr.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[4]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001, 0x00000000 });

// Set rp = s1 * s2.
gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H2, &H0})
Dim rp As New mp_ptr(New UInteger(3) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1, &H0})

' Set rp = s1 * s2.
gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_nand_n Method

gmp_libmpn_nand_n Method
Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_nand_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_nand_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_nand_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_nand_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });

// Set rp = not(s1 and s2).
gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
 rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H1, &H12345678})

' Set rp = not(s1 and s2).
gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nior_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_neg Method

gmp_libmpn_neg Method
Perform the negation of {sp, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_neg(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n
)
Public Shared Function mpn_neg (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_neg(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_neg :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of sp and rp.

Return Value

Type: mp_limb_t
Return borrow, either 0 or 1.
Remarks

This is equivalent to calling mpn_sub_n with a n-limb zero minuend and passing {sp, n} as subtrahend.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x0000001, 0x00000000 });

// Set rp = -sp.
mp_limb_t borrow = gmp_lib.mpn_neg(rp, sp, sp.Size);

// Assert result of operation.
Assert.IsTrue(borrow == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H1, &H0})

' Set rp = -sp.
Dim borrow As mp_limb_t = gmp_lib.mpn_neg(rp, sp, sp.Size)

' Assert result of operation.
Assert.IsTrue(borrow = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_nior_n Method

gmp_libmpn_nior_n Method
Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_nior_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_nior_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_nior_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_nior_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = not (s1 or s2).
gmp_lib.mpn_nior_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = not (s1 or s2).
gmp_lib.mpn_nior_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_xor_n
mpn_xnor_n


gmp_lib.mpn_perfect_power_p Method

gmp_libmpn_perfect_power_p Method
Return non-zero iff {sp, n} is a perfect power.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpn_perfect_power_p(
    mp_ptr sp,
    mp_size_t n
)
Public Shared Function mpn_perfect_power_p (
    sp As mp_ptr,
    n As mp_size_t
) As Integer
public:
static int mpn_perfect_power_p(
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_perfect_power_p :
        sp : mp_ptr *
        n : mp_size_t -> int

Parameters

sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The numbe rof limbs of sp.

Return Value

Type: Int32
Non-zero iff {sp, n} is a perfect power.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0xd4a51000, 0x000000e8 });

// Assert s1p is a perfect power.
Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) != 0);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &Hd4a51000UI, &He8})

' Assert s1p is a perfect power.
Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) <> 0)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cmp
mpn_perfect_square_p
mpn_zero_p


gmp_lib.mpn_perfect_square_p Method

gmp_libmpn_perfect_square_p Method
Return non-zero iff {s1p, n} is a perfect square.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpn_perfect_square_p(
    mp_ptr s1p,
    mp_size_t n
)
Public Shared Function mpn_perfect_square_p (
    s1p As mp_ptr,
    n As mp_size_t
) As Integer
public:
static int mpn_perfect_square_p(
    mp_ptr^ s1p,
    mp_size_t n
)
static member mpn_perfect_square_p :
        s1p : mp_ptr *
        n : mp_size_t -> int

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The numbe rof limbs of s1p.

Return Value

Type: Int32
Non-zero iff {s1p, n} is a perfect square.
Remarks

The most significant limb of the input {s1p, n} must be non-zero.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });

// Assert s1p is not a perfect square.
Assert.IsTrue(gmp_lib.mpn_perfect_square_p(s1p, s1p.Size) == 0);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})

' Assert s1p is not a perfect square.
Assert.IsTrue(gmp_lib.mpn_perfect_square_p(s1p, s1p.Size) = 0)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cmp
mpn_perfect_power_p
mpn_zero_p


gmp_lib.mpn_popcount Method

gmp_libmpn_popcount Method
Count the number of set bits in {s1p, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpn_popcount(
    mp_ptr s1p,
    mp_size_t n
)
Public Shared Function mpn_popcount (
    s1p As mp_ptr,
    n As mp_size_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpn_popcount(
    mp_ptr^ s1p,
    mp_size_t n
)
static member mpn_popcount :
        s1p : mp_ptr *
        n : mp_size_t -> mp_bitcnt_t

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.

Return Value

Type: mp_bitcnt_t
The number of set bits in {s1p, n}.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 });

// Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) == 2);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &H1, &H1})

' Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) = 2)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_hamdist
mpn_lshift
mpn_rshift
mpn_scan0
mpn_scan1


gmp_lib.mpn_random Method

gmp_libmpn_random Method
Generate a random number of length r1n and store it at r1p.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_random(
    mp_ptr r1p,
    mp_size_t r1n
)
Public Shared Sub mpn_random (
    r1p As mp_ptr,
    r1n As mp_size_t
)
public:
static void mpn_random(
    mp_ptr^ r1p,
    mp_size_t r1n
)
static member mpn_random :
        r1p : mp_ptr *
        r1n : mp_size_t -> unit

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
The result integer.
r1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of r1p.
Remarks

The most significant limb is always non-zero. mpn_random generates uniformly distributed limb data, mpn_random2 generates long strings of zeros and ones in the binary representation.

mpn_random2 is intended for testing the correctness of the mpn routines.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr r1p = new mp_ptr(new uint[2]);

// Generate random number.
gmp_lib.mpn_random(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1);

// Release unmanaged memory.
gmp_lib.free(r1p);
' Create multi-precision operand.
Dim r1p As New mp_ptr(New UInteger(1) { })

' Generate random number.
gmp_lib.mpn_random(r1p, If(gmp_lib.mp_bytes_per_limb = 4, 2, 1))

' Release unmanaged memory.
gmp_lib.free(r1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_random2


gmp_lib.mpn_random2 Method

gmp_libmpn_random2 Method
Generate a random number of length r1n and store it at r1p.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_random2(
    mp_ptr r1p,
    mp_size_t r1n
)
Public Shared Sub mpn_random2 (
    r1p As mp_ptr,
    r1n As mp_size_t
)
public:
static void mpn_random2(
    mp_ptr^ r1p,
    mp_size_t r1n
)
static member mpn_random2 :
        r1p : mp_ptr *
        r1n : mp_size_t -> unit

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
The result integer.
r1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of r1p.
Remarks

The most significant limb is always non-zero. mpn_random generates uniformly distributed limb data, mpn_random2 generates long strings of zeros and ones in the binary representation.

mpn_random2 is intended for testing the correctness of the mpn routines.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr r1p = new mp_ptr(new uint[2]);

// Generate random number.
gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1);

// Release unmanaged memory.
gmp_lib.free(r1p);
' Create multi-precision operand.
Dim r1p As New mp_ptr(New UInteger(1) { })

' Generate random number.
gmp_lib.mpn_random2(r1p, If(gmp_lib.mp_bytes_per_limb = 4, 2, 1))

' Release unmanaged memory.
gmp_lib.free(r1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_random


gmp_lib.mpn_rshift Method

gmp_libmpn_rshift Method
Shift {sp, n} right by count bits, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_rshift(
    mp_ptr rp,
    mp_ptr sp,
    mp_size_t n,
    uint count
)
Public Shared Function mpn_rshift (
    rp As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t,
    count As UInteger
) As mp_limb_t
public:
static mp_limb_t mpn_rshift(
    mp_ptr^ rp,
    mp_ptr^ sp,
    mp_size_t n,
    unsigned int count
)
static member mpn_rshift :
        rp : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t *
        count : uint32 -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of sp and rp.
count
Type: SystemUInt32

Return Value

Type: mp_limb_t
The bits shifted out at the right are returned in the most significant count bits of the return value (the rest of the return value is zero).
Remarks

count must be in the range 1 to mp_bits_per_limb - 1. The regions {sp, n} and {rp, n} may overlap, provided rp ≤ sp.

This function is written in assembly for most CPUs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0x7fffffff });

// Set rp = sp >> 1.
mp_limb_t bits = gmp_lib.mpn_rshift(rp, sp, sp.Size, 1);

// Assert result of operation.
Assert.IsTrue(bits == (gmp_lib.mp_bytes_per_limb == 4 ? 0x80000000 : 0x8000000000000000));
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &H7fffffff})

' Set rp = sp >> 1.
Dim bits As mp_limb_t = gmp_lib.mpn_rshift(rp, sp, sp.Size, 1)

' Assert result of operation.
Assert.IsTrue(bits = (If(gmp_lib.mp_bytes_per_limb = 4, &H80000000UI, &H8000000000000000UL)))
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_hamdist
mpn_lshift
mpn_popcount
mpn_scan0
mpn_scan1


gmp_lib.mpn_scan0 Method

gmp_libmpn_scan0 Method
Scan s1p from bit position bit for the next clear bit.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpn_scan0(
    mp_ptr s1p,
    mp_bitcnt_t bit
)
Public Shared Function mpn_scan0 (
    s1p As mp_ptr,
    bit As mp_bitcnt_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpn_scan0(
    mp_ptr^ s1p,
    mp_bitcnt_t bit
)
static member mpn_scan0 :
        s1p : mp_ptr *
        bit : mp_bitcnt_t -> mp_bitcnt_t

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
bit
Type: Math.Gmp.Nativemp_bitcnt_t
The index of the starting bit.

Return Value

Type: mp_bitcnt_t
The index of the next clear bit.
Remarks

It is required that there be a clear bit within the area at s1p at or beyond bit position bit, so that the function has something to return.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 });

// Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_scan0(s1p, 0) == 1);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &H1, &H1})

' Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_scan0(s1p, 0) = 1)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_hamdist
mpn_lshift
mpn_popcount
mpn_rshift
mpn_scan1


gmp_lib.mpn_scan1 Method

gmp_libmpn_scan1 Method
Scan s1p from bit position bit for the next set bit.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpn_scan1(
    mp_ptr s1p,
    mp_bitcnt_t bit
)
Public Shared Function mpn_scan1 (
    s1p As mp_ptr,
    bit As mp_bitcnt_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpn_scan1(
    mp_ptr^ s1p,
    mp_bitcnt_t bit
)
static member mpn_scan1 :
        s1p : mp_ptr *
        bit : mp_bitcnt_t -> mp_bitcnt_t

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
bit
Type: Math.Gmp.Nativemp_bitcnt_t
The index of the starting bit.

Return Value

Type: mp_bitcnt_t
The index of the next set bit.
Remarks

It is required that there be a set bit within the area at s1p at or beyond bit position bit, so that the function has something to return.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 });

// Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_scan1(s1p, 1) == 32);

// Release unmanaged memory.
gmp_lib.free(s1p);
' Create multi-precision operand.
Dim s1p As New mp_ptr(New UInteger() { &H1, &H1})

' Assert result of operation.
Assert.IsTrue(gmp_lib.mpn_scan1(s1p, 1) = 32)

' Release unmanaged memory.
gmp_lib.free(s1p)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_hamdist
mpn_lshift
mpn_popcount
mpn_rshift
mpn_scan0


gmp_lib.mpn_sec_add_1 Method

gmp_libmpn_sec_add_1 Method
Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sec_add_1(
    mp_ptr rp,
    mp_ptr ap,
    mp_size_t n,
    mp_limb_t b,
    mp_ptr tp
)
Public Shared Function mpn_sec_add_1 (
    rp As mp_ptr,
    ap As mp_ptr,
    n As mp_size_t,
    b As mp_limb_t,
    tp As mp_ptr
) As mp_limb_t
public:
static mp_limb_t mpn_sec_add_1(
    mp_ptr^ rp,
    mp_ptr^ ap,
    mp_size_t n,
    mp_limb_t b,
    mp_ptr^ tp
)
static member mpn_sec_add_1 :
        rp : mp_ptr *
        ap : mp_ptr *
        n : mp_size_t *
        b : mp_limb_t *
        tp : mp_ptr -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and rp.
b
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.

Return Value

Type: mp_limb_t
Returns carry, either 0 or 1.
Remarks

This function takes O(N) time, unlike the leaky functions mpn_add_1 which is O(1) on average. It requires scratch space of mpn_sec_add_1_itch(n) limbs, to be passed in the tp parameter. The scratch space requirements are guaranteed to be at most n limbs, and increase monotonously in the operand size.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
mp_ptr rp = new mp_ptr(result.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_add_1_itch(ap.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = ap + 1.
mp_limb_t carry = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp);

// Assert result of operation.
Assert.IsTrue(carry == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim result As New mp_ptr(New UInteger() { &H0, &H0})
Dim rp As New mp_ptr(result.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_add_1_itch(ap.Size)
Dim tp As New mp_ptr(size)

' Set rp = ap + 1.
Dim carry As mp_limb_t = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp)

' Assert result of operation.
Assert.IsTrue(carry = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1_itch
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_add_1_itch Method

gmp_libmpn_sec_add_1_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_add_1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_add_1_itch(
    mp_size_t n
)
Public Shared Function mpn_sec_add_1_itch (
    n As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_add_1_itch(
    mp_size_t n
)
static member mpn_sec_add_1_itch :
        n : mp_size_t -> mp_size_t

Parameters

n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_add_1 operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_add_1.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_add_1


gmp_lib.mpn_sec_div_qr Method

gmp_libmpn_sec_div_qr Method
Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sec_div_qr(
    mp_ptr qp,
    mp_ptr np,
    mp_size_t nn,
    mp_ptr dp,
    mp_size_t dn,
    mp_ptr tp
)
Public Shared Function mpn_sec_div_qr (
    qp As mp_ptr,
    np As mp_ptr,
    nn As mp_size_t,
    dp As mp_ptr,
    dn As mp_size_t,
    tp As mp_ptr
) As mp_limb_t
public:
static mp_limb_t mpn_sec_div_qr(
    mp_ptr^ qp,
    mp_ptr^ np,
    mp_size_t nn,
    mp_ptr^ dp,
    mp_size_t dn,
    mp_ptr^ tp
)
static member mpn_sec_div_qr :
        qp : mp_ptr *
        np : mp_ptr *
        nn : mp_size_t *
        dp : mp_ptr *
        dn : mp_size_t *
        tp : mp_ptr -> mp_limb_t

Parameters

qp
Type: Math.Gmp.Nativemp_ptr
The quotient result operand.
np
Type: Math.Gmp.Nativemp_ptr
The first operand and remainder result integer.
nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of np.
dp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of dp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.

Return Value

Type: mp_limb_t
Q’s most significant limb.
Remarks

It is required that nn ≥ dn ≥ 1, and that dp[dn - 1] ≠ 0. This does not imply that N ≥ D since N might be zero-padded.

Note the overlapping between N and R. No other operand overlapping is allowed. The entire space occupied by N is overwritten.

This function requires scratch space of mpn_sec_div_qr_itch(nn, dn) limbs to be passed in the tp parameter.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr dp = new mp_ptr(new uint[] { 0x00000003 });
mp_ptr remainder = new mp_ptr(new uint[] { 0x00000000 });
mp_ptr qp = new mp_ptr(new uint[np.Size]);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size);
mp_ptr tp = new mp_ptr(size);

// Set qp = floor(np / dp) and rp = np mod dp.
mp_limb_t mslimb = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp);

// Assert result of operation.
Assert.IsTrue(mslimb == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x00005555 : 0x0000555555555555));
Assert.IsTrue(qp[0] == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x55555555 : 0x0000000000000000));
Assert.IsTrue(np[0] == remainder[0]);

// Release unmanaged memory.
gmp_lib.free(qp, np, dp, remainder, tp);
' Create multi-precision operands, and expected result.
Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim dp As New mp_ptr(New UInteger() { &H3})
Dim remainder As New mp_ptr(New UInteger() { &H0})
Dim qp As New mp_ptr(New UInteger(np.Size - 1) { })

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size)
Dim tp As New mp_ptr(size)

' Set qp = floor(np / dp) and rp = np mod dp.
Dim mslimb As mp_limb_t = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp)

' Assert result of operation.
Assert.IsTrue(mslimb = CULng(If(gmp_lib.mp_bytes_per_limb = 4, &H5555, &H555555555555L)))
Assert.IsTrue(qp(0) = CULng(If(gmp_lib.mp_bytes_per_limb = 4, &H55555555, &H0)))
Assert.IsTrue(np(0) = remainder(0))

' Release unmanaged memory.
gmp_lib.free(qp, np, dp, remainder, tp)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr_itch
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_div_qr_itch Method

gmp_libmpn_sec_div_qr_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_div_qr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_div_qr_itch(
    mp_size_t nn,
    mp_size_t dn
)
Public Shared Function mpn_sec_div_qr_itch (
    nn As mp_size_t,
    dn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_div_qr_itch(
    mp_size_t nn,
    mp_size_t dn
)
static member mpn_sec_div_qr_itch :
        nn : mp_size_t *
        dn : mp_size_t -> mp_size_t

Parameters

nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_div_qr first operand.
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_div_qr second operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_div_qr.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_div_qr


gmp_lib.mpn_sec_div_r Method

gmp_libmpn_sec_div_r Method
Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sec_div_r(
    mp_ptr np,
    mp_size_t nn,
    mp_ptr dp,
    mp_size_t dn,
    mp_ptr tp
)
Public Shared Sub mpn_sec_div_r (
    np As mp_ptr,
    nn As mp_size_t,
    dp As mp_ptr,
    dn As mp_size_t,
    tp As mp_ptr
)
public:
static void mpn_sec_div_r(
    mp_ptr^ np,
    mp_size_t nn,
    mp_ptr^ dp,
    mp_size_t dn,
    mp_ptr^ tp
)
static member mpn_sec_div_r :
        np : mp_ptr *
        nn : mp_size_t *
        dp : mp_ptr *
        dn : mp_size_t *
        tp : mp_ptr -> unit

Parameters

np
Type: Math.Gmp.Nativemp_ptr
The first operand and result integer.
nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of np.
dp
Type: Math.Gmp.Nativemp_ptr
The second operand integer
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of dp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that nn ≥ dn ≥ 1, and that dp[dn - 1] ≠ 0. This does not imply that N ≥ D since N might be zero-padded.

Note the overlapping between N and R. No other operand overlapping is allowed. The entire space occupied by N is overwritten.

This function requires scratch space of mpn_sec_div_r_itch(nn, dn) limbs to be passed in the tp parameter.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 });

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size);
mp_ptr tp = new mp_ptr(size);

// Set np = np mod dp.
gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp);

// Assert result of operation.
Assert.IsTrue(np[0] == 3);

// Release unmanaged memory.
gmp_lib.free(np, dp, tp);
' Create multi-precision operands, and expected result.
Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim dp As New mp_ptr(New UInteger() { &H4})

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size)
Dim tp As New mp_ptr(size)

' Set np = np mod dp.
gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp)

' Assert result of operation.
Assert.IsTrue(np(0) = 3)

' Release unmanaged memory.
gmp_lib.free(np, dp, tp)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r_itch
mpn_sec_invert


gmp_lib.mpn_sec_div_r_itch Method

gmp_libmpn_sec_div_r_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_div_r.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_div_r_itch(
    mp_size_t nn,
    mp_size_t dn
)
Public Shared Function mpn_sec_div_r_itch (
    nn As mp_size_t,
    dn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_div_r_itch(
    mp_size_t nn,
    mp_size_t dn
)
static member mpn_sec_div_r_itch :
        nn : mp_size_t *
        dn : mp_size_t -> mp_size_t

Parameters

nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_div_r first operand.
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_div_r second operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_div_r.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_div_r


gmp_lib.mpn_sec_invert Method

gmp_libmpn_sec_invert Method
Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpn_sec_invert(
    mp_ptr rp,
    mp_ptr ap,
    mp_ptr mp,
    mp_size_t n,
    mp_bitcnt_t nbcnt,
    mp_ptr tp
)
Public Shared Function mpn_sec_invert (
    rp As mp_ptr,
    ap As mp_ptr,
    mp As mp_ptr,
    n As mp_size_t,
    nbcnt As mp_bitcnt_t,
    tp As mp_ptr
) As Integer
public:
static int mpn_sec_invert(
    mp_ptr^ rp,
    mp_ptr^ ap,
    mp_ptr^ mp,
    mp_size_t n,
    mp_bitcnt_t nbcnt,
    mp_ptr^ tp
)
static member mpn_sec_invert :
        rp : mp_ptr *
        ap : mp_ptr *
        mp : mp_ptr *
        n : mp_size_t *
        nbcnt : mp_bitcnt_t *
        tp : mp_ptr -> int

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
mp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and mp.
nbcnt
Type: Math.Gmp.Nativemp_bitcnt_t
The third operand integer.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.

Return Value

Type: Int32
If an inverse exists, return 1, otherwise return 0 and leave R undefined.
Remarks

If an inverse exists, return 1, otherwise return 0 and leave R undefined. In either case, the input A is destroyed.

It is required that M is odd, and that nbcnt ≥ ceil(log(A + 1)) + ceil(log(M + 1)). A safe choice is nbcnt = 2 * n * mp_bits_per_limb, but a smaller value might improve performance if M or A are known to have leading zero bits.

This function requires scratch space of mpn_sec_invert_itch(n) limbs to be passed in the tp parameter.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 3 });
mp_ptr mp = new mp_ptr(new uint[] { 11 });
mp_ptr rp = new mp_ptr(ap.Size);
mp_ptr result = new mp_ptr(new uint[] { 4 });

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_invert_itch(ap.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = ap^-1 mod mp.
gmp_lib.mpn_sec_invert(rp, ap, mp, ap.Size, (uint)(2 * ap.Size* gmp_lib.mp_bits_per_limb), tp);

// Assert result of operation.
Assert.IsTrue(rp[0] == result[0]);

// Release unmanaged memory.
gmp_lib.free(ap, mp, rp, result, tp);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert_itch


gmp_lib.mpn_sec_invert_itch Method

gmp_libmpn_sec_invert_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_invert.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_invert_itch(
    mp_size_t n
)
Public Shared Function mpn_sec_invert_itch (
    n As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_invert_itch(
    mp_size_t n
)
static member mpn_sec_invert_itch :
        n : mp_size_t -> mp_size_t

Parameters

n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_invert first operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_invert.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_invert


gmp_lib.mpn_sec_mul Method

gmp_libmpn_sec_mul Method
Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sec_mul(
    mp_ptr rp,
    mp_ptr ap,
    mp_size_t an,
    mp_ptr bp,
    mp_size_t bn,
    mp_ptr tp
)
Public Shared Sub mpn_sec_mul (
    rp As mp_ptr,
    ap As mp_ptr,
    an As mp_size_t,
    bp As mp_ptr,
    bn As mp_size_t,
    tp As mp_ptr
)
public:
static void mpn_sec_mul(
    mp_ptr^ rp,
    mp_ptr^ ap,
    mp_size_t an,
    mp_ptr^ bp,
    mp_size_t bn,
    mp_ptr^ tp
)
static member mpn_sec_mul :
        rp : mp_ptr *
        ap : mp_ptr *
        an : mp_size_t *
        bp : mp_ptr *
        bn : mp_size_t *
        tp : mp_ptr -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
an
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap.
bp
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
bn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of bp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that an ≥ bn > 0.

No overlapping between R and the input operands is allowed. For A = B, use mpn_sec_sqr for optimal performance.

This function requires scratch space of mpn_sec_mul_itch(an, bn) limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand sizes.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 });
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 });
mp_ptr rp = new mp_ptr(ap.Size + bp.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = ap * bp.
gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, ap, bp, tp, result);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim bp As New mp_ptr(New UInteger() { &H2})
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1})
Dim rp As New mp_ptr(ap.Size + bp.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size)
Dim tp As New mp_ptr(size)

' Set rp = ap * bp.
gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, ap, bp, tp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul_itch
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_mul_itch Method

gmp_libmpn_sec_mul_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_mul.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_mul_itch(
    mp_size_t an,
    mp_size_t bn
)
Public Shared Function mpn_sec_mul_itch (
    an As mp_size_t,
    bn As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_mul_itch(
    mp_size_t an,
    mp_size_t bn
)
static member mpn_sec_mul_itch :
        an : mp_size_t *
        bn : mp_size_t -> mp_size_t

Parameters

an
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_mul first operand.
bn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_mul second operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_mul.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_mul


gmp_lib.mpn_sec_powm Method

gmp_libmpn_sec_powm Method
Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sec_powm(
    mp_ptr rp,
    mp_ptr bp,
    mp_size_t bn,
    mp_ptr ep,
    mp_bitcnt_t enb,
    mp_ptr mp,
    mp_size_t n,
    mp_ptr tp
)
Public Shared Sub mpn_sec_powm (
    rp As mp_ptr,
    bp As mp_ptr,
    bn As mp_size_t,
    ep As mp_ptr,
    enb As mp_bitcnt_t,
    mp As mp_ptr,
    n As mp_size_t,
    tp As mp_ptr
)
public:
static void mpn_sec_powm(
    mp_ptr^ rp,
    mp_ptr^ bp,
    mp_size_t bn,
    mp_ptr^ ep,
    mp_bitcnt_t enb,
    mp_ptr^ mp,
    mp_size_t n,
    mp_ptr^ tp
)
static member mpn_sec_powm :
        rp : mp_ptr *
        bp : mp_ptr *
        bn : mp_size_t *
        ep : mp_ptr *
        enb : mp_bitcnt_t *
        mp : mp_ptr *
        n : mp_size_t *
        tp : mp_ptr -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result operand.
bp
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
bn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of bp.
ep
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
enb
Type: Math.Gmp.Nativemp_bitcnt_t
The number of limbs of ep.
mp
Type: Math.Gmp.Nativemp_ptr
The third operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of mp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that B > 0, that M > 0 is odd, and that E < 2^enb.

No overlapping between R and the input operands is allowed.

This function requires scratch space of mpn_sec_powm_itch(bn, enb, n) limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand sizes.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 });
mp_ptr ep = new mp_ptr(new uint[] { 0x00000004 });
mp_ptr mp = new mp_ptr(new uint[] { 0x00000003 });
mp_ptr result = new mp_ptr(new uint[] { 0x00000001 });
mp_ptr rp = new mp_ptr(bp.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_powm_itch(bp.Size, 3, mp.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = bp^ep mod mp.
gmp_lib.mpn_sec_powm(rp, bp, bp.Size, ep, 3, mp, mp.Size, tp);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, bp, ep, mp, tp, result);
' Create multi-precision operands, and expected result.
Dim bp As New mp_ptr(New UInteger() { &H2})
Dim ep As New mp_ptr(New UInteger() { &H4})
Dim mp As New mp_ptr(New UInteger() { &H3})
Dim result As New mp_ptr(New UInteger() { &H1})
Dim rp As New mp_ptr(bp.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_powm_itch(bp.Size, 3, mp.Size)
Dim tp As New mp_ptr(size)

' Set rp = bp^ep mod mp.
gmp_lib.mpn_sec_powm(rp, bp, bp.Size, ep, 3, mp, mp.Size, tp)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, bp, ep, mp, tp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm_itch
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_powm_itch Method

gmp_libmpn_sec_powm_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_powm.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_powm_itch(
    mp_size_t bn,
    mp_bitcnt_t enb,
    mp_size_t n
)
Public Shared Function mpn_sec_powm_itch (
    bn As mp_size_t,
    enb As mp_bitcnt_t,
    n As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_powm_itch(
    mp_size_t bn,
    mp_bitcnt_t enb,
    mp_size_t n
)
static member mpn_sec_powm_itch :
        bn : mp_size_t *
        enb : mp_bitcnt_t *
        n : mp_size_t -> mp_size_t

Parameters

bn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_powm first operand.
enb
Type: Math.Gmp.Nativemp_bitcnt_t
The number of limbs of the mpn_sec_powm second operand.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_powm third operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_powm.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_powm


gmp_lib.mpn_sec_sqr Method

gmp_libmpn_sec_sqr Method
Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sec_sqr(
    mp_ptr rp,
    mp_ptr ap,
    mp_size_t an,
    mp_ptr tp
)
Public Shared Sub mpn_sec_sqr (
    rp As mp_ptr,
    ap As mp_ptr,
    an As mp_size_t,
    tp As mp_ptr
)
public:
static void mpn_sec_sqr(
    mp_ptr^ rp,
    mp_ptr^ ap,
    mp_size_t an,
    mp_ptr^ tp
)
static member mpn_sec_sqr :
        rp : mp_ptr *
        ap : mp_ptr *
        an : mp_size_t *
        tp : mp_ptr -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result operand.
ap
Type: Math.Gmp.Nativemp_ptr
The operand integer.
an
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that an > 0.

No overlapping between R and the input operands is allowed.

This function requires scratch space of mpn_sec_sqr_itch(an) limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand size.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0xfffffffe, 0xffffffff });
mp_ptr rp = new mp_ptr(2 * ap.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_sqr_itch(ap.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = s1^2.
gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim result As New mp_ptr(New UInteger() { &H1, &H0, &HfffffffeUI, &HffffffffUI})
Dim rp As New mp_ptr(2 * ap.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_sqr_itch(ap.Size)
Dim tp As New mp_ptr(size)

' Set rp = s1^2.
gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr_itch
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_sqr_itch Method

gmp_libmpn_sec_sqr_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_sqr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_sqr_itch(
    mp_size_t an
)
Public Shared Function mpn_sec_sqr_itch (
    an As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_sqr_itch(
    mp_size_t an
)
static member mpn_sec_sqr_itch :
        an : mp_size_t -> mp_size_t

Parameters

an
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_sqr operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_sqr.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_sqr


gmp_lib.mpn_sec_sub_1 Method

gmp_libmpn_sec_sub_1 Method
Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sec_sub_1(
    mp_ptr rp,
    mp_ptr ap,
    mp_size_t n,
    mp_limb_t b,
    mp_ptr tp
)
Public Shared Function mpn_sec_sub_1 (
    rp As mp_ptr,
    ap As mp_ptr,
    n As mp_size_t,
    b As mp_limb_t,
    tp As mp_ptr
) As mp_limb_t
public:
static mp_limb_t mpn_sec_sub_1(
    mp_ptr^ rp,
    mp_ptr^ ap,
    mp_size_t n,
    mp_limb_t b,
    mp_ptr^ tp
)
static member mpn_sec_sub_1 :
        rp : mp_ptr *
        ap : mp_ptr *
        n : mp_size_t *
        b : mp_limb_t *
        tp : mp_ptr -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
ap
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of ap and rp.
b
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.

Return Value

Type: mp_limb_t
Returns borrow, either 0 or 1.
Remarks

This function takes O(N) time, unlike the leaky functions mpn_sub_1 which is O(1) on average. It requires scratch space of mpn_sec_sub_1_itch(n) limbs, to be passed in the tp parameter. The scratch space requirements are guaranteed to be at most n limbs, and increase monotonously in the operand size.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });
mp_ptr rp = new mp_ptr(result.Size);

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_sub_1_itch(ap.Size);
mp_ptr tp = new mp_ptr(size);

// Set rp = ap - 1.
mp_limb_t borrow = gmp_lib.mpn_sec_sub_1(rp, ap, ap.Size, 1, tp);

// Assert result of operation.
Assert.IsTrue(borrow == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result);
' Create multi-precision operands, and expected result.
Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})
Dim rp As New mp_ptr(result.Size)

' Create scratch space.
Dim size As mp_size_t = gmp_lib.mpn_sec_sub_1_itch(ap.Size)
Dim tp As New mp_ptr(size)

' Set rp = ap - 1.
Dim borrow As mp_limb_t = gmp_lib.mpn_sec_sub_1(rp, ap, ap.Size, 1, tp)

' Assert result of operation.
Assert.IsTrue(borrow = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, ap, tp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1_itch
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_tabselect
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_sec_sub_1_itch Method

gmp_libmpn_sec_sub_1_itch Method
Return the scratch space in number of limbs required by the function mpn_sec_sub_1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sec_sub_1_itch(
    mp_size_t n
)
Public Shared Function mpn_sec_sub_1_itch (
    n As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sec_sub_1_itch(
    mp_size_t n
)
static member mpn_sec_sub_1_itch :
        n : mp_size_t -> mp_size_t

Parameters

n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of the mpn_sec_sub_1 operand.

Return Value

Type: mp_size_t
The scratch space in number of limbs required by the function mpn_sec_sub_1.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_sec_sub_1


gmp_lib.mpn_sec_tabselect Method

gmp_libmpn_sec_tabselect Method
Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sec_tabselect(
    mp_ptr rp,
    mp_ptr tab,
    mp_size_t n,
    mp_size_t nents,
    mp_size_t which
)
Public Shared Sub mpn_sec_tabselect (
    rp As mp_ptr,
    tab As mp_ptr,
    n As mp_size_t,
    nents As mp_size_t,
    which As mp_size_t
)
public:
static void mpn_sec_tabselect(
    mp_ptr^ rp,
    mp_ptr^ tab,
    mp_size_t n,
    mp_size_t nents,
    mp_size_t which
)
static member mpn_sec_tabselect :
        rp : mp_ptr *
        tab : mp_ptr *
        n : mp_size_t *
        nents : mp_size_t *
        which : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
tab
Type: Math.Gmp.Nativemp_ptr
The table of operand integers.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in each entry of the table.
nents
Type: Math.Gmp.Nativemp_size_t
The number of entries in the table.
which
Type: Math.Gmp.Nativemp_size_t
The zero-based index of the entry to select.
Remarks

This function reads the entire table to avoid side-channel information leaks.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr tab = new mp_ptr(new uint[] { 0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x33333333, 0x00000000 });
mp_ptr result = new mp_ptr(new uint[] { 0x33333333 });
mp_ptr rp = new mp_ptr(result.Size);

// Set rp to third entry in tab.
gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(tab, result);
' Create multi-precision operands, and expected result.
Dim tab As New mp_ptr(New UInteger() { &H11111111, &H22222222, &H33333333, &H44444444, &H33333333, &H0})
Dim result As New mp_ptr(New UInteger() { &H33333333})
Dim rp As New mp_ptr(result.Size)

' Set rp to third entry in tab.
gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(tab, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cnd_add_n
mpn_cnd_sub_n
mpn_sec_add_1
mpn_sec_sub_1
mpn_cnd_swap
mpn_sec_mul
mpn_sec_sqr
mpn_sec_powm
mpn_sec_powm_itch
mpn_sec_div_qr
mpn_sec_div_r
mpn_sec_invert


gmp_lib.mpn_set_str Method

gmp_libmpn_set_str Method
Convert bytes {str, strsize} in the given base to limbs at rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_set_str(
    mp_ptr rp,
    char_ptr str,
    size_t strsize,
    int base
)
Public Shared Function mpn_set_str (
    rp As mp_ptr,
    str As char_ptr,
    strsize As size_t,
    base As Integer
) As mp_size_t
public:
static mp_size_t mpn_set_str(
    mp_ptr^ rp,
    char_ptr str,
    size_t strsize,
    int base
)
static member mpn_set_str :
        rp : mp_ptr *
        str : char_ptr *
        strsize : size_t *
        base : int -> mp_size_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
str
Type: Math.Gmp.Nativechar_ptr
The operand string.
strsize
Type: Math.Gmp.Nativesize_t
The length of str.
base
Type: SystemInt32

Return Value

Type: mp_size_t
The number of limbs of rp.
Remarks

str[0] is the most significant input byte and str[strsize - 1] is the least significant input byte. Each byte should be a value in the range 0 to base - 1, not an ASCII character. base can vary from 2 to 256.

The converted value is {rp, rn} where rn is the return value. If the most significant input byte str[0] is non-zero, then rp[rn - 1] will be non-zero, else rp[rn - 1] and some number of subsequent limbs may be zero.

The area at rp has to have space for the largest possible number with strsize digits in the chosen base, plus one extra limb.

The input must have at least one byte, and no overlap is permitted between {str, strsize} and the result at rp.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands.
mp_ptr rp = new mp_ptr(new uint[2]);
byte[] s = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 };
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000001 });
char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx");
Marshal.Copy(s, 0, str.ToIntPtr(), 9);

// Convert rp from str in hex base.
mp_size_t count = gmp_lib.mpn_set_str(rp, str, 9, 16);

// Assert the non-ASCII, hex representation of s1p.
Assert.IsTrue(count == rp.Size);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp);
gmp_lib.free(str);
' Create multi-precision operands.
Dim rp As New mp_ptr(New UInteger(1) { })
Dim s As Byte() = New Byte() { 1, 0, 0, 0, 0, 0, 0, 0, 1}
Dim result As New mp_ptr(New UInteger() { &H1, &H1})
Dim str As New char_ptr("xxxxxxxxxxxxxxxxx")
Marshal.Copy(s, 0, str.ToIntPtr(), 9)

' Convert rp from str in hex base.
Dim count As mp_size_t = gmp_lib.mpn_set_str(rp, str, 9, 16)

' Assert the non-ASCII, hex representation of s1p.
Assert.IsTrue(count = rp.Size)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp)
gmp_lib.free(str)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_get_str
mpn_sizeinbase


gmp_lib.mpn_sizeinbase Method

gmp_libmpn_sizeinbase Method
Return the size of {xp, n} measured in number of digits in the given base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpn_sizeinbase(
    mp_ptr xp,
    mp_size_t n,
    int base
)
Public Shared Function mpn_sizeinbase (
    xp As mp_ptr,
    n As mp_size_t,
    base As Integer
) As size_t
public:
static size_t mpn_sizeinbase(
    mp_ptr^ xp,
    mp_size_t n,
    int base
)
static member mpn_sizeinbase :
        xp : mp_ptr *
        n : mp_size_t *
        base : int -> size_t

Parameters

xp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of xp.
base
Type: SystemInt32
The base.

Return Value

Type: size_t
The size of {xp, n} measured in number of digits in the given base.
Remarks

base can vary from 2 to 62. Requires n > 0 and xp[n - 1] > 0. The result will be either exact or 1 too big. If base is a power of 2, the result is always exact.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr xp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 });

// Assert that the number of bits required is 33.
Assert.IsTrue(gmp_lib.mpn_sizeinbase(xp, xp.Size, 2) == 33);

// Release unmanaged memory.
gmp_lib.free(xp);
' Create multi-precision operands, and expected result.
Dim xp As New mp_ptr(New UInteger() { &H1, &H1})

' Assert that the number of bits required is 33.
Assert.IsTrue(gmp_lib.mpn_sizeinbase(xp, xp.Size, 2) = 33)

' Release unmanaged memory.
gmp_lib.free(xp)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_get_str
mpn_set_str


gmp_lib.mpn_sqr Method

gmp_libmpn_sqr Method
Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_sqr(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n
)
Public Shared Sub mpn_sqr (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_sqr(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n
)
static member mpn_sqr :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
Remarks

The destination has to have space for 2 * n limbs, even if the result’s most significant limb is zero. No overlap is permitted between the destination and the source.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[4]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0xfffffffe, 0xffffffff });

// Set rp = s1^2.
gmp_lib.mpn_sqr(rp, s1p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(3) { })
Dim result As New mp_ptr(New UInteger() { &H1, &H0, &HfffffffeUI, &HffffffffUI})

' Set rp = s1^2.
gmp_lib.mpn_sqr(rp, s1p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_sqrtrem Method

gmp_libmpn_sqrtrem Method
Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpn_sqrtrem(
    mp_ptr r1p,
    mp_ptr r2p,
    mp_ptr sp,
    mp_size_t n
)
Public Shared Function mpn_sqrtrem (
    r1p As mp_ptr,
    r2p As mp_ptr,
    sp As mp_ptr,
    n As mp_size_t
) As mp_size_t
public:
static mp_size_t mpn_sqrtrem(
    mp_ptr^ r1p,
    mp_ptr^ r2p,
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_sqrtrem :
        r1p : mp_ptr *
        r2p : mp_ptr *
        sp : mp_ptr *
        n : mp_size_t -> mp_size_t

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
The first result integer.
r2p
Type: Math.Gmp.Nativemp_ptr
The second result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integwer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of sp.

Return Value

Type: mp_size_t
The number of limbs of r2p.
Remarks

r2p needs space for n limbs, but the return value indicates how many are produced.

The most significant limb of {sp, n} must be non-zero. The areas {r1p, ceil(n / 2)} and {sp, n} must be completely separate. The areas {r2p, n} and {sp, n} must be either identical or completely separate.

If the remainder is not wanted then r2p can be NULL, and in this case the return value is zero or non-zero according to whether the remainder would have been zero or non-zero.

A return value of zero indicates a perfect square. See also mpn_perfect_square_p.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 });
mp_ptr r1p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]);
mp_ptr r2p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]);
mp_ptr result = new mp_ptr(new uint[] { 0x00010000, 0x00000000 });
mp_ptr remainder = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });

// Set r1p = trunc(sqrt(sp)), r2p = sp - r1p^2
mp_size_t r2n = gmp_lib.mpn_sqrtrem(r1p, r2p, sp, sp.Size);

// Assert result.
Assert.IsTrue(r2n == 1);
 Assert.IsTrue(r1p.SequenceEqual(result));
Assert.IsTrue(r2p.SequenceEqual(remainder));

// Release unmanaged memory.
gmp_lib.free(sp, r1p, r2p, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &H1, &H1})
Dim r1p As New mp_ptr(New UInteger(sp.Size * (gmp_lib.mp_bytes_per_limb / 4) - 1) {})
Dim r2p As New mp_ptr(New UInteger(sp.Size * (gmp_lib.mp_bytes_per_limb / 4) - 1) {})
Dim result As New mp_ptr(New UInteger() { &H10000, &H0})
Dim remainder As New mp_ptr(New UInteger() { &H1, &H0})

' Set r1p = trunc(sqrt(sp)), r2p = sp - r1p^2
Dim r2n As mp_size_t = gmp_lib.mpn_sqrtrem(r1p, r2p, sp, sp.Size)

' Assert result.
Assert.IsTrue(r2n = 1)
Assert.IsTrue(r1p.SequenceEqual(result))
Assert.IsTrue(r2p.SequenceEqual(remainder))

' Release unmanaged memory.
gmp_lib.free(sp, r1p, r2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_tdiv_qr


gmp_lib.mpn_sub Method

gmp_libmpn_sub Method
Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sub(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t s1n,
    mp_ptr s2p,
    mp_size_t s2n
)
Public Shared Function mpn_sub (
    rp As mp_ptr,
    s1p As mp_ptr,
    s1n As mp_size_t,
    s2p As mp_ptr,
    s2n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_sub(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t s1n,
    mp_ptr^ s2p,
    mp_size_t s2n
)
static member mpn_sub :
        rp : mp_ptr *
        s1p : mp_ptr *
        s1n : mp_size_t *
        s2p : mp_ptr *
        s2n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
s2n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s2p.

Return Value

Type: mp_limb_t
Return borrow, either 0 or 1.
Remarks

This is the lowest-level function for subtraction. It is the preferred function for subtraction, since it is written in assembly for most CPUs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });

// Set rp = s1 - s2.
mp_limb_t borrow = gmp_lib.mpn_sub(rp, s1p, s1p.Size, s2p, s2p.Size);

// Assert result of operation.
Assert.IsTrue(borrow == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})

' Set rp = s1 - s2.
Dim borrow As mp_limb_t = gmp_lib.mpn_sub(rp, s1p, s1p.Size, s2p, s2p.Size)

' Assert result of operation.
Assert.IsTrue(borrow = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_sub_1 Method

gmp_libmpn_sub_1 Method
Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sub_1(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
Public Shared Function mpn_sub_1 (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_sub_1(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
static member mpn_sub_1 :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The numbe rof limbs of s1p.
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
Return borrow, either 0 or 1.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });

// Set rp = s1 - 1.
mp_limb_t borrow = gmp_lib.mpn_sub_1(rp, s1p, s1p.Size, 1);

// Assert result of operation.
Assert.IsTrue(borrow == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})

' Set rp = s1 - 1.
Dim borrow As mp_limb_t = gmp_lib.mpn_sub_1(rp, s1p, s1p.Size, 1)

' Assert result of operation.
Assert.IsTrue(borrow = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_sub_n Method

gmp_libmpn_sub_n Method
Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_sub_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Function mpn_sub_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpn_sub_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_sub_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The numbe rof limbs of s1p and s2p.

Return Value

Type: mp_limb_t
Return borrow, either 0 or 1.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });

// Set rp = s1 - s2.
mp_limb_t borrow = gmp_lib.mpn_sub_n(rp, s1p, s2p, rp.Size);

// Assert result of operation.
Assert.IsTrue(borrow == 0);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H0})
 Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})

' Set rp = s1 - s2.
Dim borrow As mp_limb_t = gmp_lib.mpn_sub_n(rp, s1p, s2p, rp.Size)

' Assert result of operation.
Assert.IsTrue(borrow = 0)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_submul_1
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_submul_1 Method

gmp_libmpn_submul_1 Method
Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpn_submul_1(
    mp_ptr rp,
    mp_ptr s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
Public Shared Function mpn_submul_1 (
    rp As mp_ptr,
    s1p As mp_ptr,
    n As mp_size_t,
    s2limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_submul_1(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_size_t n,
    mp_limb_t s2limb
)
static member mpn_submul_1 :
        rp : mp_ptr *
        s1p : mp_ptr *
        n : mp_size_t *
        s2limb : mp_limb_t -> mp_limb_t

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p
s2limb
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.

Return Value

Type: mp_limb_t
Return the most significant limb of the product, plus borrow-out from the subtraction.
Remarks

{s1p, n} and {rp, n} are allowed to overlap provided rp ≤ s1p.

This is a low-level function that is a building block for general multiplication and division as well as other operations in GMP. It is written in assembly for most CPUs.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 });
mp_ptr result = new mp_ptr(new uint[] { 0x00000004, 0x00000000 });

// Set rp -= s1 * 2.
mp_limb_t borrow = gmp_lib.mpn_submul_1(rp, s1p, s1p.Size, 2);

// Assert result of operation.
Assert.IsTrue(borrow == 0x02);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger() { &H2, &H0})
Dim result As New mp_ptr(New UInteger() { &H4, &H0})

' Set rp -= s1 * 2.
Dim borrow As mp_limb_t = gmp_lib.mpn_submul_1(rp, s1p, s1p.Size, 2)

' Assert result of operation.
Assert.IsTrue(borrow = &H2)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_sqr
mpn_sqrtrem
mpn_tdiv_qr


gmp_lib.mpn_tdiv_qr Method

gmp_libmpn_tdiv_qr Method
Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_tdiv_qr(
    mp_ptr qp,
    mp_ptr rp,
    mp_size_t qxn,
    mp_ptr np,
    mp_size_t nn,
    mp_ptr dp,
    mp_size_t dn
)
Public Shared Sub mpn_tdiv_qr (
    qp As mp_ptr,
    rp As mp_ptr,
    qxn As mp_size_t,
    np As mp_ptr,
    nn As mp_size_t,
    dp As mp_ptr,
    dn As mp_size_t
)
public:
static void mpn_tdiv_qr(
    mp_ptr^ qp,
    mp_ptr^ rp,
    mp_size_t qxn,
    mp_ptr^ np,
    mp_size_t nn,
    mp_ptr^ dp,
    mp_size_t dn
)
static member mpn_tdiv_qr :
        qp : mp_ptr *
        rp : mp_ptr *
        qxn : mp_size_t *
        np : mp_ptr *
        nn : mp_size_t *
        dp : mp_ptr *
        dn : mp_size_t -> unit

Parameters

qp
Type: Math.Gmp.Nativemp_ptr
The result quotient integer.
rp
Type: Math.Gmp.Nativemp_ptr
The result remainder integer.
qxn
Type: Math.Gmp.Nativemp_size_t
Must be 0.
np
Type: Math.Gmp.Nativemp_ptr
The numerator operand integer.
nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of np.
dp
Type: Math.Gmp.Nativemp_ptr
The denominator operand integer.
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of dp.
Remarks

The quotient is rounded towards 0.

No overlap is permitted between arguments, except that np might equal rp. The dividend size nn must be greater than or equal to divisor size dn. The most significant limb of the divisor must be non-zero. The qxn operand must be zero.

Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr dp = new mp_ptr(new uint[] { 0x00000013 });
mp_ptr qp = new mp_ptr(new uint[np.Size - dp.Size + 1]);
mp_ptr rp = new mp_ptr(new uint[dp.Size]);
mp_ptr quotient = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 });
mp_ptr remainder = new mp_ptr(new uint[] { 0x0000000a });

// Set rp = np / dp.
gmp_lib.mpn_tdiv_qr(qp, rp, 0, np, np.Size, dp, dp.Size);

// Assert result of operation.
Assert.IsTrue(qp.SequenceEqual(quotient));
Assert.IsTrue(rp.SequenceEqual(remainder));

// Release unmanaged memory.
gmp_lib.free(qp, rp, np, dp, quotient, remainder);
' Create multi-precision operands, and expected result.
Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim dp As New mp_ptr(New UInteger() { &H13})
Dim qp As New mp_ptr(New UInteger(np.Size - dp.Size) { })
Dim rp As New mp_ptr(New UInteger(dp.Size - 1) { })
Dim quotient As New mp_ptr(New UInteger() { &H435e50d7, &Hd79})
Dim remainder As New mp_ptr(New UInteger() { &Ha})

' Set rp = np / dp.
gmp_lib.mpn_tdiv_qr(qp, rp, 0, np, np.Size, dp, dp.Size)

' Assert result of operation.
Assert.IsTrue(qp.SequenceEqual(quotient))
Assert.IsTrue(rp.SequenceEqual(remainder))

' Release unmanaged memory.
gmp_lib.free(qp, rp, np, dp, quotient, remainder)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_add
mpn_add_1
mpn_add_n
mpn_addmul_1
mpn_divexact_1
mpn_divexact_by3
mpn_divexact_by3c
mpn_divmod_1
mpn_divrem_1
mpn_mod_1
mpn_mul
mpn_mul_1
mpn_mul_n
mpn_neg
mpn_sub
mpn_sub_1
mpn_sub_n
mpn_submul_1
mpn_sqr
mpn_sqrtrem


gmp_lib.mpn_xnor_n Method

gmp_libmpn_xnor_n Method
Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_xnor_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_xnor_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_xnor_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_xnor_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });

// Set rp = not(s1 xor s2).
gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H1, &H12345678})

' Set rp = not(s1 xor s2).
gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xor_n


gmp_lib.mpn_xor_n Method

gmp_libmpn_xor_n Method
Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_xor_n(
    mp_ptr rp,
    mp_ptr s1p,
    mp_ptr s2p,
    mp_size_t n
)
Public Shared Sub mpn_xor_n (
    rp As mp_ptr,
    s1p As mp_ptr,
    s2p As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_xor_n(
    mp_ptr^ rp,
    mp_ptr^ s1p,
    mp_ptr^ s2p,
    mp_size_t n
)
static member mpn_xor_n :
        rp : mp_ptr *
        s1p : mp_ptr *
        s2p : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operands, and expected result.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 });

// Set rp = s1 xor s2.
gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result);
' Create multi-precision operands, and expected result.
Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI})
Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &Hedcba987UI})

' Set rp = s1 xor s2.
gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, s1p, s2p, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_and_n
mpn_andn_n
mpn_com
mpn_ior_n
mpn_iorn_n
mpn_nand_n
mpn_nior_n
mpn_xnor_n


gmp_lib.mpn_zero Method

gmp_libmpn_zero Method
Zero {rp, n}.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpn_zero(
    mp_ptr rp,
    mp_size_t n
)
Public Shared Sub mpn_zero (
    rp As mp_ptr,
    n As mp_size_t
)
public:
static void mpn_zero(
    mp_ptr^ rp,
    mp_size_t n
)
static member mpn_zero :
        rp : mp_ptr *
        n : mp_size_t -> unit

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of rp.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand, and expected result.
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Set rp = sp.
gmp_lib.mpn_zero(rp, rp.Size);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, result);
' Create multi-precision operand, and expected result.
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H0, &H0})

' Set rp = sp.
gmp_lib.mpn_zero(rp, rp.Size)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, result)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_copyd
mpn_copyi


gmp_lib.mpn_zero_p Method

gmp_libmpn_zero_p Method
Test {sp, n} and return 1 if the operand is zero, 0 otherwise.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpn_zero_p(
    mp_ptr sp,
    mp_size_t n
)
Public Shared Function mpn_zero_p (
    sp As mp_ptr,
    n As mp_size_t
) As Integer
public:
static int mpn_zero_p(
    mp_ptr^ sp,
    mp_size_t n
)
static member mpn_zero_p :
        sp : mp_ptr *
        n : mp_size_t -> int

Parameters

sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in sp.

Return Value

Type: Int32
Return 1 if the operand is zero, 0 otherwise.
Examples
C#
VB
C++
F#
Copy
// Create multi-precision operand.
mp_ptr sp = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });

// Assert sp == 0.
Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) == 1);

// Release unmanaged memory.
gmp_lib.free(sp);
' Create multi-precision operand.
Dim sp As New mp_ptr(New UInteger() { &H0, &H0})

' Assert sp == 0.
Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) = 1)

' Release unmanaged memory.
gmp_lib.free(sp)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpn_cmp
mpn_perfect_power_p
mpn_perfect_square_p


gmp_lib.mpq_abs Method

gmp_libmpq_abs Method
Set rop to the absolute value of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_abs(
    mpq_t rop,
    mpq_t op
)
Public Shared Sub mpq_abs (
    rop As mpq_t,
    op As mpq_t
)
public:
static void mpq_abs(
    mpq_t^ rop,
    mpq_t^ op
)
static member mpq_abs :
        rop : mpq_t *
        op : mpq_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_neg
mpq_inv


gmp_lib.mpq_add Method

gmp_libmpq_add Method
Set sum to addend1 + addend2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_add(
    mpq_t sum,
    mpq_t addend1,
    mpq_t addend2
)
Public Shared Sub mpq_add (
    sum As mpq_t,
    addend1 As mpq_t,
    addend2 As mpq_t
)
public:
static void mpq_add(
    mpq_t^ sum,
    mpq_t^ addend1,
    mpq_t^ addend2
)
static member mpq_add :
        sum : mpq_t *
        addend1 : mpq_t *
        addend2 : mpq_t -> unit

Parameters

sum
Type: Math.Gmp.Nativempq_t
The result rational.
addend1
Type: Math.Gmp.Nativempq_t
The first operand rational.
addend2
Type: Math.Gmp.Nativempq_t
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_canonicalize Method

gmp_libmpq_canonicalize Method
Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_canonicalize(
    mpq_t op
)
Public Shared Sub mpq_canonicalize (
    op As mpq_t
)
public:
static void mpq_canonicalize(
    mpq_t^ op
)
static member mpq_canonicalize :
        op : mpq_t -> unit

Parameters

op
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_init
mpq_inits
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_clear Method

gmp_libmpq_clear Method
Free the space occupied by x.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_clear(
    mpq_t x
)
Public Shared Sub mpq_clear (
    x As mpq_t
)
public:
static void mpq_clear(
    mpq_t^ x
)
static member mpq_clear :
        x : mpq_t -> unit

Parameters

x
Type: Math.Gmp.Nativempq_t
The operand rational.
Remarks

Make sure to call this function for all mpq_t variables when you are done with them.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational x.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) == 0.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpq_clear(x);
' Create and initialize a new rational x.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)

' Assert that the value of x is 0.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) = 0.0)

' Release unmanaged memory allocated for x.
gmp_lib.mpq_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_clears Method

gmp_libmpq_clears Method
Free the space occupied by a NULL-terminated list of mpq_t variables.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_clears(
    params mpq_t[] x
)
Public Shared Sub mpq_clears (
    ParamArray x As mpq_t()
)
public:
static void mpq_clears(
    ... array<mpq_t^>^ x
)
static member mpq_clears :
        x : mpq_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
// Create new rationals x1, x2 and x3.
mpq_t x1 = new mpq_t();
mpq_t x2 = new mpq_t();
mpq_t x3 = new mpq_t();

// Initialize the rationals.
gmp_lib.mpq_inits(x1, x2, x3, null);

// Assert that their value is 0.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0);
Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0);
Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0);

// Release unmanaged memory allocated for the rationals.
gmp_lib.mpq_clears(x1, x2, x3, null);
' Create new rationals x1, x2 and x3.
Dim x1 As New mpq_t()
Dim x2 As New mpq_t()
Dim x3 As New mpq_t()

' Initialize the rationals.
gmp_lib.mpq_inits(x1, x2, x3, Nothing)

' Assert that their value is 0.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x1) = 0.0)
Assert.IsTrue(gmp_lib.mpq_get_d(x2) = 0.0)
Assert.IsTrue(gmp_lib.mpq_get_d(x3) = 0.0)

' Release unmanaged memory allocated for the rationals.
gmp_lib.mpq_clears(x1, x2, x3, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_cmp Method

gmp_libmpq_cmp Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_cmp(
    mpq_t op1,
    mpq_t op2
)
Public Shared Function mpq_cmp (
    op1 As mpq_t,
    op2 As mpq_t
) As Integer
public:
static int mpq_cmp(
    mpq_t^ op1,
    mpq_t^ op2
)
static member mpq_cmp :
        op1 : mpq_t *
        op2 : mpq_t -> int

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: Math.Gmp.Nativempq_t
The second operand rational.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Remarks

To determine if two rationals are equal, mpq_equal is faster than mpq_cmp.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Create, initialize, and set the value of op2 to 1 / 3.
mpq_t op2 = new mpq_t();
gmp_lib.mpq_init(op2);
gmp_lib.mpq_set_si(op2, 1, 3U);

// Assert that op1 > op2.
Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clears(op1, op2, null);
' Create, initialize, and set the value of op1 to 1 / 2.
Dim op1 As New mpq_t()
gmp_lib.mpq_init(op1)
gmp_lib.mpq_set_si(op1, 1, 2UI)

' Create, initialize, and set the value of op2 to 1 / 3.
Dim op2 As New mpq_t()
gmp_lib.mpq_init(op2)
gmp_lib.mpq_set_si(op2, 1, 3UI)

' Assert that op1 > op2.
Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clears(op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp_z
mpq_cmp_ui
mpq_cmp_si
mpq_sgn
mpq_equal


gmp_lib.mpq_cmp_si Method

gmp_libmpq_cmp_si Method
Compare op1 and num2 / den2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_cmp_si(
    mpq_t op1,
    int num2,
    uint den2
)
Public Shared Function mpq_cmp_si (
    op1 As mpq_t,
    num2 As Integer,
    den2 As UInteger
) As Integer
public:
static int mpq_cmp_si(
    mpq_t^ op1,
    int num2,
    unsigned int den2
)
static member mpq_cmp_si :
        op1 : mpq_t *
        num2 : int *
        den2 : uint32 -> int

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
num2
Type: SystemInt32
The second operand numerator integer.
den2
Type: SystemUInt32
The second operand denominator integer.

Return Value

Type: Int32
Return a positive value if op1 > num2 / den2, zero if op1 = num2 / den2, and a negative value if op1 < num2 / den2.
Remarks

num2 and den2 are allowed to have common factors.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Assert that op1 < 5/6.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6U) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpq_clear(op1);
' Create, initialize, and set the value of op1 to 1 / 2.
Dim op1 As New mpq_t()
gmp_lib.mpq_init(op1)
gmp_lib.mpq_set_si(op1, 1, 2UI)

' Assert that op1 < 5/6.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6UI) < 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpq_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp
mpq_cmp_z
mpq_cmp_ui
mpq_sgn
mpq_equal


gmp_lib.mpq_cmp_ui Method

gmp_libmpq_cmp_ui Method
Compare op1 and num2 / den2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_cmp_ui(
    mpq_t op1,
    uint num2,
    uint den2
)
Public Shared Function mpq_cmp_ui (
    op1 As mpq_t,
    num2 As UInteger,
    den2 As UInteger
) As Integer
public:
static int mpq_cmp_ui(
    mpq_t^ op1,
    unsigned int num2,
    unsigned int den2
)
static member mpq_cmp_ui :
        op1 : mpq_t *
        num2 : uint32 *
        den2 : uint32 -> int

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
num2
Type: SystemUInt32
The second operand numerator integer.
den2
Type: SystemUInt32
The second operand denominator integer.

Return Value

Type: Int32
Return a positive value if op1 > num2 / den2, zero if op1 = num2 / den2, and a negative value if op1 < num2 / den2.
Remarks

num2 and den2 are allowed to have common factors.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Assert that op1 == 3/6.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6U) == 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpq_clear(op1);
' Create, initialize, and set the value of op1 to 1 / 2.
Dim op1 As New mpq_t()
gmp_lib.mpq_init(op1)
gmp_lib.mpq_set_si(op1, 1, 2UI)

' Assert that op1 == 3/6.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6UI) = 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpq_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp
mpq_cmp_z
mpq_cmp_si
mpq_sgn
mpq_equal


gmp_lib.mpq_cmp_z Method

gmp_libmpq_cmp_z Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_cmp_z(
    mpq_t op1,
    mpz_t op2
)
Public Shared Function mpq_cmp_z (
    op1 As mpq_t,
    op2 As mpz_t
) As Integer
public:
static int mpq_cmp_z(
    mpq_t^ op1,
    mpz_t^ op2
)
static member mpq_cmp_z :
        op1 : mpq_t *
        op2 : mpz_t -> int

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: Math.Gmp.Nativempz_t
The second operand rational.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Remarks

To determine if two rationals are equal, mpq_equal is faster than mpq_cmp.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Create, initialize, and set the value of op2 to 3.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init(op2);
gmp_lib.mpz_set_si(op2, 3);

// Assert that op1 < op2.
Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clear(op1);
gmp_lib.mpz_clear(op2);
' Create, initialize, and set the value of op1 to 1 / 2.
Dim op1 As New mpq_t()
gmp_lib.mpq_init(op1)
gmp_lib.mpq_set_si(op1, 1, 2UI)

' Create, initialize, and set the value of op2 to 3.
Dim op2 As New mpz_t()
gmp_lib.mpz_init(op2)
gmp_lib.mpz_set_si(op2, 3)

' Assert that op1 < op2.
Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clear(op1)
gmp_lib.mpz_clear(op2)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp
mpq_cmp_ui
mpq_cmp_si
mpq_sgn
mpq_equal


gmp_lib.mpq_denref Method

gmp_libmpq_denref Method
Return a reference to the denominator op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mpz_t mpq_denref(
    mpq_t op
)
Public Shared Function mpq_denref (
    op As mpq_t
) As mpz_t
public:
static mpz_t^ mpq_denref(
    mpq_t^ op
)
static member mpq_denref :
        op : mpq_t -> mpz_t

Parameters

op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: mpz_t
Return a reference to the denominator op.
Remarks

The mpz functions can be used on the returned reference.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Get reference to denominator, and increment it by 2.
mpz_t num = gmp_lib.mpq_denref(op);
gmp_lib.mpz_add_ui(num, num, 2U);

// Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Get reference to denominator, and increment it by 2.
Dim num As mpz_t = gmp_lib.mpq_denref(op)
gmp_lib.mpz_add_ui(num, num, 2UI)

' Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5UI) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_numref
mpq_get_num
mpq_get_den
mpq_set_num
mpq_set_den


gmp_lib.mpq_div Method

gmp_libmpq_div Method
Set quotient to dividend / divisor.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_div(
    mpq_t quotient,
    mpq_t dividend,
    mpq_t divisor
)
Public Shared Sub mpq_div (
    quotient As mpq_t,
    dividend As mpq_t,
    divisor As mpq_t
)
public:
static void mpq_div(
    mpq_t^ quotient,
    mpq_t^ dividend,
    mpq_t^ divisor
)
static member mpq_div :
        quotient : mpq_t *
        dividend : mpq_t *
        divisor : mpq_t -> unit

Parameters

quotient
Type: Math.Gmp.Nativempq_t
The result rational.
dividend
Type: Math.Gmp.Nativempq_t
The first operand rational.
divisor
Type: Math.Gmp.Nativempq_t
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div_2exp
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_div_2exp Method

gmp_libmpq_div_2exp Method
Set rop to op1 / 2^op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_div_2exp(
    mpq_t rop,
    mpq_t op1,
    uint op2
)
Public Shared Sub mpq_div_2exp (
    rop As mpq_t,
    op1 As mpq_t,
    op2 As UInteger
)
public:
static void mpq_div_2exp(
    mpq_t^ rop,
    mpq_t^ op1,
    unsigned int op2
)
static member mpq_div_2exp :
        rop : mpq_t *
        op1 : mpq_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: SystemUInt32
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_equal Method

gmp_libmpq_equal Method
Return non-zero if op1 and op2 are equal, zero if they are non-equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_equal(
    mpq_t op1,
    mpq_t op2
)
Public Shared Function mpq_equal (
    op1 As mpq_t,
    op2 As mpq_t
) As Integer
public:
static int mpq_equal(
    mpq_t^ op1,
    mpq_t^ op2
)
static member mpq_equal :
        op1 : mpq_t *
        op2 : mpq_t -> int

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: Math.Gmp.Nativempq_t
The second operand rational.

Return Value

Type: Int32
Return non-zero if op1 and op2 are equal, zero if they are non-equal.
Remarks

Although mpq_cmp can be used for the same purpose, this function is much faster.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Create, initialize, and set the value of op2 to 1 / 3.
mpq_t op2 = new mpq_t();
gmp_lib.mpq_init(op2);
gmp_lib.mpq_set_si(op2, 1, 3U);

// Assert that op1 != op2.
Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) == 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clears(op1, op2, null);
' Create, initialize, and set the value of op1 to 1 / 2.
Dim op1 As New mpq_t()
gmp_lib.mpq_init(op1)
gmp_lib.mpq_set_si(op1, 1, 2UI)

' Create, initialize, and set the value of op2 to 1 / 3.
Dim op2 As New mpq_t()
gmp_lib.mpq_init(op2)
gmp_lib.mpq_set_si(op2, 1, 3UI)

' Assert that op1 != op2.
Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) = 0)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clears(op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp
mpq_cmp_z
mpq_cmp_ui
mpq_cmp_si
mpq_sgn


gmp_lib.mpq_get_d Method

gmp_libmpq_get_d Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static double mpq_get_d(
    mpq_t op
)
Public Shared Function mpq_get_d (
    op As mpq_t
) As Double
public:
static double mpq_get_d(
    mpq_t^ op
)
static member mpq_get_d :
        op : mpq_t -> float

Parameters

op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: Double
The converted double.
Remarks

If the exponent from the conversion is too big or too small to fit a double then the result is system dependent. For too big an infinity is returned when available. For too small 0.0 is normally returned. Hardware overflow, underflow and denorm traps may or may not occur.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11U);

// Assert that the value of x is 10.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0 / 11.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpq_clear(x);
' Create, initialize, and set the value of x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11UI)

' Assert that the value of x is 10.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) = 10.0 / 11.0)

' Release unmanaged memory allocated for x.
gmp_lib.mpq_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_set_d
mpq_set_f
mpq_get_str


gmp_lib.mpq_get_den Method

gmp_libmpq_get_den Method
Set denominator to the denominator of rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_get_den(
    mpz_t denominator,
    mpq_t rational
)
Public Shared Sub mpq_get_den (
    denominator As mpz_t,
    rational As mpq_t
)
public:
static void mpq_get_den(
    mpz_t^ denominator,
    mpq_t^ rational
)
static member mpq_get_den :
        denominator : mpz_t *
        rational : mpq_t -> unit

Parameters

denominator
Type: Math.Gmp.Nativempz_t
The result integer.
rational
Type: Math.Gmp.Nativempq_t
The operand rational.
Remarks

The function is equivalent to calling mpz_set with mpq_denref. Direct use of mpq_denref is recommended instead of this functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Create and initialize a new integer.
mpz_t den = new mpz_t();
gmp_lib.mpz_init(den);

// Set integer to numerator of rational, and increment integer by 2..
gmp_lib.mpq_get_den(den, op);
gmp_lib.mpz_add_ui(den, den, 2U);

// Assert that num is 1, and op is -1 / 3.
Assert.IsTrue(gmp_lib.mpz_cmp_si(den, 5) == 0);
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0);

// Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op);
gmp_lib.mpz_clear(den);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Create and initialize a new integer.
Dim den As New mpz_t()
gmp_lib.mpz_init(den)

' Set integer to numerator of rational, and increment integer by 2..
gmp_lib.mpq_get_den(den, op)
gmp_lib.mpz_add_ui(den, den, 2UI)

' Assert that num is 1, and op is -1 / 3.
Assert.IsTrue(gmp_lib.mpz_cmp_si(den, 5) = 0)
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3UI) = 0)

' Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op)
gmp_lib.mpz_clear(den)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_numref
mpq_denref
mpq_get_num
mpq_get_den
mpq_set_num
mpq_set_den


gmp_lib.mpq_get_num Method

gmp_libmpq_get_num Method
Set numerator to the numerator of rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_get_num(
    mpz_t numerator,
    mpq_t rational
)
Public Shared Sub mpq_get_num (
    numerator As mpz_t,
    rational As mpq_t
)
public:
static void mpq_get_num(
    mpz_t^ numerator,
    mpq_t^ rational
)
static member mpq_get_num :
        numerator : mpz_t *
        rational : mpq_t -> unit

Parameters

numerator
Type: Math.Gmp.Nativempz_t
The result integer.
rational
Type: Math.Gmp.Nativempq_t
The operand rational.
Remarks

The function is equivalent to calling mpz_set with mpq_numref. Direct use of mpq_numref is recommended instead of this functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Create and initialize a new integer.
mpz_t num = new mpz_t();
gmp_lib.mpz_init(num);

// Set integer to numerator of rational, and increment integer by 2.
gmp_lib.mpq_get_num(num, op);
gmp_lib.mpz_add_ui(num, num, 2U);

// Assert that num is 1, and op is -1 / 3.
Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) == 0);
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0);

// Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op);
gmp_lib.mpz_clear(num);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Create and initialize a new integer.
Dim num As New mpz_t()
gmp_lib.mpz_init(num)

' Set integer to numerator of rational, and increment integer by 2.
gmp_lib.mpq_get_num(num, op)
gmp_lib.mpz_add_ui(num, num, 2UI)

' Assert that num is 1, and op is -1 / 3.
Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) = 0)
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3UI) = 0)

' Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op)
gmp_lib.mpz_clear(num)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_numref
mpq_denref
mpq_get_den
mpq_set_num
mpq_set_den


gmp_lib.mpq_get_str Method

gmp_libmpq_get_str Method
Convert op to a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static char_ptr mpq_get_str(
    char_ptr str,
    int base,
    mpq_t op
)
Public Shared Function mpq_get_str (
    str As char_ptr,
    base As Integer,
    op As mpq_t
) As char_ptr
public:
static char_ptr mpq_get_str(
    char_ptr str,
    int base,
    mpq_t^ op
)
static member mpq_get_str :
        str : char_ptr *
        base : int *
        op : mpq_t -> char_ptr

Parameters

str
Type: Math.Gmp.Nativechar_ptr
The result string.
base
Type: SystemInt32
The base.
op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: char_ptr
A pointer to the result string is returned, being either the allocated block, or the given str.
Remarks

The base may vary from 2 to 36. The string will be of the form "num/den", or if the denominator is 1 then just "num".

If str is NULL, the result string is allocated using the current allocation function (see GNU MP - Custom Allocation). The block will be strlen(str) + 1 bytes, that being exactly enough for the string and null-terminator.

If str is not NULL, it should point to a block of storage large enough for the result, that being

C++
Copy
mpz_sizeinbase(mpq_numref(op), base) + mpz_sizeinbase(mpq_denref(op), base) + 3

The three extra bytes are for a possible minus sign, possible slash, and the null-terminator.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -210 / 13.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, -210, 13U);

// Retrieve the string value of x, and assert that it is "-210/13".
char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == "-210/13");

// Release unmanaged memory allocated for x and the string value.
gmp_lib.mpq_clear(x);
gmp_lib.free(s);
' Create, initialize, and set the value of x to -210 / 13.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, -210, 13UI)

' Retrieve the string value of x, and assert that it is "-210/13".
Dim s As char_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x)
Assert.IsTrue(s.ToString() = "-210/13")

' Release unmanaged memory allocated for x and the string value.
gmp_lib.mpq_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_get_d
mpq_set_d
mpq_set_f


gmp_lib.mpq_init Method

gmp_libmpq_init Method
Initialize x and set it to 0/1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_init(
    mpq_t x
)
Public Shared Sub mpq_init (
    x As mpq_t
)
public:
static void mpq_init(
    mpq_t^ x
)
static member mpq_init :
        x : mpq_t -> unit

Parameters

x
Type: Math.Gmp.Nativempq_t
The operand rational.
Remarks

Each variable should normally only be initialized once, or at least cleared out (using the function mpq_clear) between each initialization.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational x.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Assert that the value of x is 0.
char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == "0");

// Release unmanaged memory allocated for x and its string value.
gmp_lib.mpq_clear(x);
gmp_lib.free(s);
' Create and initialize a new rational x.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)

' Assert that the value of x is 0.
Dim s As char_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x)
Assert.IsTrue(s.ToString() = "0")

' Release unmanaged memory allocated for x and its string value.
gmp_lib.mpq_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_inits Method

gmp_libmpq_inits Method
Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_inits(
    params mpq_t[] x
)
Public Shared Sub mpq_inits (
    ParamArray x As mpq_t()
)
public:
static void mpq_inits(
    ... array<mpq_t^>^ x
)
static member mpq_inits :
        x : mpq_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
// Create new rationals x1, x2 and x3.
mpq_t x1 = new mpq_t();
mpq_t x2 = new mpq_t();
mpq_t x3 = new mpq_t();

// Initialize the rationals.
gmp_lib.mpq_inits(x1, x2, x3);

// Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0);
Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0);
Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0);

// Release unmanaged memory allocated for the rationals.
gmp_lib.mpq_clears(x1, x2, x3, null);
' Create new rationals x1, x2 and x3.
Dim x1 As New mpq_t()
Dim x2 As New mpq_t()
Dim x3 As New mpq_t()

' Initialize the rationals.
gmp_lib.mpq_inits(x1, x2, x3)

' Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpq_get_d(x1) = 0.0)
Assert.IsTrue(gmp_lib.mpq_get_d(x2) = 0.0)
Assert.IsTrue(gmp_lib.mpq_get_d(x3) = 0.0)

' Release unmanaged memory allocated for the rationals.
gmp_lib.mpq_clears(x1, x2, x3, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_inp_str Method

gmp_libmpq_inp_str Method
Read a string of digits from stream and convert them to a rational in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpq_inp_str(
    mpq_t rop,
    ptr<FILE> stream,
    int base
)
Public Shared Function mpq_inp_str (
    rop As mpq_t,
    stream As ptr(Of FILE),
    base As Integer
) As size_t
public:
static size_t mpq_inp_str(
    mpq_t^ rop,
    ptr<FILE>^ stream,
    int base
)
static member mpq_inp_str :
        rop : mpq_t *
        stream : ptr<FILE> *
        base : int -> size_t

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base.

Return Value

Type: size_t
Return the number of characters read (including white space), or 0 if a rational could not be read.
Remarks

Any initial white-space characters are read and discarded.

The input can be a fraction like "17/63" or just an integer like "123". Reading stops at the first character not in this form, and white space is not permitted within the string. If the input might not be in canonical form, then mpq_canonicalize must be called (see GNU MP - Rational Number Functions).

The base can be between 2 and 36, or can be 0 in which case the leading characters of the string determine the base, "0x" or "0X" for hexadecimal, "0" for octal, or decimal otherwise. The leading characters are examined separately for the numerator and denominator of a fraction, so for instance "0x10/11" is 16/11, whereas "0x10/0x11" is 16/17.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123/456.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);

// Write rational to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(pathname, "123/456");

// Read op from the temporary file, and assert that the number of bytes read is 7.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) == 7);
fclose(stream.Value.Value);

// Assert that op is 123/456.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456U) == 0);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op);
' Create, initialize, and set the value of op to 123/456.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)

' Write rational to a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()
System.IO.File.WriteAllText(pathname, "123/456")

' Read op from the temporary file, and assert that the number of bytes read is 7.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) = 7)
fclose(stream.Value.Value)

' Assert that op is 123/456.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456UI) = 0)

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_out_str


gmp_lib.mpq_inv Method

gmp_libmpq_inv Method
Set inverted_number to 1 / number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_inv(
    mpq_t inverted_number,
    mpq_t number
)
Public Shared Sub mpq_inv (
    inverted_number As mpq_t,
    number As mpq_t
)
public:
static void mpq_inv(
    mpq_t^ inverted_number,
    mpq_t^ number
)
static member mpq_inv :
        inverted_number : mpq_t *
        number : mpq_t -> unit

Parameters

inverted_number
Type: Math.Gmp.Nativempq_t
The result rational.
number
Type: Math.Gmp.Nativempq_t
The operand rational.
Remarks

If the new denominator is zero, this routine will divide by zero.

Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_neg
mpq_abs


gmp_lib.mpq_mul Method

gmp_libmpq_mul Method
Set product to multiplier * multiplicand.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_mul(
    mpq_t product,
    mpq_t multiplier,
    mpq_t multiplicand
)
Public Shared Sub mpq_mul (
    product As mpq_t,
    multiplier As mpq_t,
    multiplicand As mpq_t
)
public:
static void mpq_mul(
    mpq_t^ product,
    mpq_t^ multiplier,
    mpq_t^ multiplicand
)
static member mpq_mul :
        product : mpq_t *
        multiplier : mpq_t *
        multiplicand : mpq_t -> unit

Parameters

product
Type: Math.Gmp.Nativempq_t
The result rational.
multiplier
Type: Math.Gmp.Nativempq_t
The first operand rational.
multiplicand
Type: Math.Gmp.Nativempq_t
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_mul_2exp Method

gmp_libmpq_mul_2exp Method
Set rop to op1 * 2*op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_mul_2exp(
    mpq_t rop,
    mpq_t op1,
    uint op2
)
Public Shared Sub mpq_mul_2exp (
    rop As mpq_t,
    op1 As mpq_t,
    op2 As UInteger
)
public:
static void mpq_mul_2exp(
    mpq_t^ rop,
    mpq_t^ op1,
    unsigned int op2
)
static member mpq_mul_2exp :
        rop : mpq_t *
        op1 : mpq_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: SystemUInt32
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_div
mpq_div_2exp
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_neg Method

gmp_libmpq_neg Method
Set negated_operand to -operand.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_neg(
    mpq_t negated_operand,
    mpq_t operand
)
Public Shared Sub mpq_neg (
    negated_operand As mpq_t,
    operand As mpq_t
)
public:
static void mpq_neg(
    mpq_t^ negated_operand,
    mpq_t^ operand
)
static member mpq_neg :
        negated_operand : mpq_t *
        operand : mpq_t -> unit

Parameters

negated_operand
Type: Math.Gmp.Nativempq_t
The result rational.
operand
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_sub
mpq_mul
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_abs
mpq_inv


gmp_lib.mpq_numref Method

gmp_libmpq_numref Method
Return a reference to the numerator op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mpz_t mpq_numref(
    mpq_t op
)
Public Shared Function mpq_numref (
    op As mpq_t
) As mpz_t
public:
static mpz_t^ mpq_numref(
    mpq_t^ op
)
static member mpq_numref :
        op : mpq_t -> mpz_t

Parameters

op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: mpz_t
Return a reference to the numerator op.
Remarks

The mpz functions can be used on the returned reference.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Get reference to numerator, and increment it by 2.
mpz_t num = gmp_lib.mpq_numref(op);
gmp_lib.mpz_add_ui(num, num, 2U);

// Assert that op is 1 / 3.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 3U) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Get reference to numerator, and increment it by 2.
Dim num As mpz_t = gmp_lib.mpq_numref(op)
gmp_lib.mpz_add_ui(num, num, 2UI)

' Assert that op is 1 / 3.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 3UI) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_denref
mpq_get_num
mpq_get_den
mpq_set_num
mpq_set_den


gmp_lib.mpq_out_str Method

gmp_libmpq_out_str Method
Output op on stdio stream stream, as a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpq_out_str(
    ptr<FILE> stream,
    int base,
    mpq_t op
)
Public Shared Function mpq_out_str (
    stream As ptr(Of FILE),
    base As Integer,
    op As mpq_t
) As size_t
public:
static size_t mpq_out_str(
    ptr<FILE>^ stream,
    int base,
    mpq_t^ op
)
static member mpq_out_str :
        stream : ptr<FILE> *
        base : int *
        op : mpq_t -> size_t

Parameters

stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base.
op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: size_t
Return the number of bytes written, or if an error occurred, return 0.
Remarks

The base may vary from 2 to 36. Output is in the form "num/den" or if the denominator is 1 then just "num".

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123/456.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_ui(op, 123, 456U);

// Get a temporary file.
string pathname = System.IO.Path.GetTempFileName();

// Open temporary file for writing.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");

// Write op to temporary file, and assert that the number of bytes written is 7.
Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) == 7);

// Close temporary file.
fclose(stream.Value.Value);

// Assert that the content of the temporary file is "123/456".
string result = System.IO.File.ReadAllText(pathname);
Assert.IsTrue(result == "123/456");

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op);
' Create, initialize, and set the value of op to 123/456.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_ui(op, 123, 456UI)

' Get a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()

' Open temporary file for writing.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "w")

' Write op to temporary file, and assert that the number of bytes written is 7.
Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) = 7)

' Close temporary file.
fclose(stream.Value.Value)

' Assert that the content of the temporary file is "123/456".
Dim result As String = System.IO.File.ReadAllText(pathname)

Assert.IsTrue(result = "123/456")

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpq_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_inp_str


gmp_lib.mpq_set Method

gmp_libmpq_set Method
Assign rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set(
    mpq_t rop,
    mpq_t op
)
Public Shared Sub mpq_set (
    rop As mpq_t,
    op As mpq_t
)
public:
static void mpq_set(
    mpq_t^ rop,
    mpq_t^ op
)
static member mpq_set :
        rop : mpq_t *
        op : mpq_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op
Type: Math.Gmp.Nativempq_t
The operand rational.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11);

// Create, initialize, and set a new rational y to -210 / 13.
mpq_t y = new mpq_t();
gmp_lib.mpq_init(y);
gmp_lib.mpq_set_si(y, -210, 13);

// Assign the value of y to x.
gmp_lib.mpq_set(x, y);

// Assert that the value of x is -210 / 13.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13) == 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, null);
' Create, initialize, and set a new rational x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11)

' Create, initialize, and set a new rational y to -210 / 13.
Dim y As New mpq_t()
gmp_lib.mpq_init(y)
gmp_lib.mpq_set_si(y, -210, 13)

' Assign the value of y to x.
gmp_lib.mpq_set(x, y)

' Assert that the value of x is -210 / 13.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13) = 0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_set_d Method

gmp_libmpq_set_d Method
Set rop to the value of op. There is no rounding, this conversion is exact.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_d(
    mpq_t rop,
    double op
)
Public Shared Sub mpq_set_d (
    rop As mpq_t,
    op As Double
)
public:
static void mpq_set_d(
    mpq_t^ rop,
    double op
)
static member mpq_set_d :
        rop : mpq_t *
        op : float -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op
Type: SystemDouble
The operand double.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Set the value of x to 10.0 / 11.0.
gmp_lib.mpq_set_d(x, 10.0D / 11.0);

// Assert that the value of x is 10.0 / 11.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0D / 11.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpq_clear(x);
' Create and initialize a new rational.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)

' Set the value of x to 10.0 / 11.0.
gmp_lib.mpq_set_d(x, 10.0 / 11.0)

' Assert that the value of x is 10.0 / 11.0.
Assert.IsTrue(gmp_lib.mpq_get_d(x) = 10.0 / 11.0)

' Release unmanaged memory allocated for x.
gmp_lib.mpq_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_get_d
mpq_set_f
mpq_get_str


gmp_lib.mpq_set_den Method

gmp_libmpq_set_den Method
Set the denominator of rational to denominator.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_den(
    mpq_t rational,
    mpz_t denominator
)
Public Shared Sub mpq_set_den (
    rational As mpq_t,
    denominator As mpz_t
)
public:
static void mpq_set_den(
    mpq_t^ rational,
    mpz_t^ denominator
)
static member mpq_set_den :
        rational : mpq_t *
        denominator : mpz_t -> unit

Parameters

rational
Type: Math.Gmp.Nativempq_t
The result rational.
denominator
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks
The function is equivalent to calling mpz_set with mpq_denref. Direct use of mpq_denref is recommended instead of this functions.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Create, initialize, and set the value of a new integer to 5.
mpz_t den = new mpz_t();
gmp_lib.mpz_init_set_ui(den, 5U);

// Set the denominator of op.
gmp_lib.mpq_set_den(op, den);

// Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0);

// Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op);
gmp_lib.mpz_clear(den);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Create, initialize, and set the value of a new integer to 5.
Dim den As New mpz_t()
gmp_lib.mpz_init_set_ui(den, 5UI)

' Set the denominator of op.
gmp_lib.mpq_set_den(op, den)

' Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5UI) = 0)

' Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op)
gmp_lib.mpz_clear(den)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_numref
mpq_denref
mpq_get_num
mpq_get_den
mpq_set_num


gmp_lib.mpq_set_f Method

gmp_libmpq_set_f Method
Set rop to the value of op. There is no rounding, this conversion is exact.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_f(
    mpq_t rop,
    mpf_t op
)
Public Shared Sub mpq_set_f (
    rop As mpq_t,
    op As mpf_t
)
public:
static void mpq_set_f(
    mpq_t^ rop,
    mpf_t^ op
)
static member mpq_set_f :
        rop : mpq_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op
Type: Math.Gmp.Nativempf_t
The operand float.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11);

// Create, initialize, and set a new float y to -210.
mpf_t y = new mpf_t();
gmp_lib.mpf_init(y);
gmp_lib.mpf_set_si(y, -210);

// Assign the value of y to x.
gmp_lib.mpq_set_f(x, y);

// Assert that the value of x is -210 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clear(x);
gmp_lib.mpf_clear(y);
' Create, initialize, and set a new rational x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11)

' Create, initialize, and set a new float y to -210.
Dim y As New mpf_t()
gmp_lib.mpf_init(y)
gmp_lib.mpf_set_si(y, -210)

' Assign the value of y to x.
gmp_lib.mpq_set_f(x, y)

' Assert that the value of x is -210 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) = 0)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_get_d
mpq_set_d
mpq_get_str


gmp_lib.mpq_set_num Method

gmp_libmpq_set_num Method
Set the numerator of rational to numerator.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_num(
    mpq_t rational,
    mpz_t numerator
)
Public Shared Sub mpq_set_num (
    rational As mpq_t,
    numerator As mpz_t
)
public:
static void mpq_set_num(
    mpq_t^ rational,
    mpz_t^ numerator
)
static member mpq_set_num :
        rational : mpq_t *
        numerator : mpz_t -> unit

Parameters

rational
Type: Math.Gmp.Nativempq_t
The result rational.
numerator
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks

The function is equivalent to calling mpz_set with mpq_numref. Direct use of mpq_numref is recommended instead of this functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Create, initialize, and set the value of a new integer to 5.
mpz_t num = new mpz_t();
gmp_lib.mpz_init_set_ui(num, 5U);

// Set the numerator of op.
gmp_lib.mpq_set_num(op, num);

// Assert that op is 5 / 3.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3U) == 0);

// Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op);
gmp_lib.mpz_clear(num);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Create, initialize, and set the value of a new integer to 5.
Dim num As New mpz_t()
gmp_lib.mpz_init_set_ui(num, 5UI)

' Set the numerator of op.
gmp_lib.mpq_set_num(op, num)

' Assert that op is 5 / 3.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3UI) = 0)

' Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op)
gmp_lib.mpz_clear(num)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_numref
mpq_denref
mpq_get_num
mpq_get_den
mpq_set_den


gmp_lib.mpq_set_si Method

gmp_libmpq_set_si Method
Set the value of rop to op1 / op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_si(
    mpq_t rop,
    int op1,
    uint op2
)
Public Shared Sub mpq_set_si (
    rop As mpq_t,
    op1 As Integer,
    op2 As UInteger
)
public:
static void mpq_set_si(
    mpq_t^ rop,
    int op1,
    unsigned int op2
)
static member mpq_set_si :
        rop : mpq_t *
        op1 : int *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op1
Type: SystemInt32
The first operand rational.
op2
Type: SystemUInt32
The second operand rational.
Remarks

Note that if op1 and op2 have common factors, rop has to be passed to mpq_canonicalize before any operations are performed on rop.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational x.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Set the value of x to -10 / 11.
gmp_lib.mpq_set_si(x, -10, 11);

// Assert that the value of x is -10 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -10, 11U) == 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpq_clear(x);
' Create and initialize a new rational x.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)

' Set the value of x to -10 / 11.
gmp_lib.mpq_set_si(x, -10, 11)

' Assert that the value of x is -10 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -10, 11UI) = 0)

' Release unmanaged memory allocated for x.
gmp_lib.mpq_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_str
mpq_swap


gmp_lib.mpq_set_str Method

gmp_libmpq_set_str Method
Set rop from a null-terminated string str in the given base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_set_str(
    mpq_t rop,
    char_ptr str,
    int base
)
Public Shared Function mpq_set_str (
    rop As mpq_t,
    str As char_ptr,
    base As Integer
) As Integer
public:
static int mpq_set_str(
    mpq_t^ rop,
    char_ptr str,
    int base
)
static member mpq_set_str :
        rop : mpq_t *
        str : char_ptr *
        base : int -> int

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
str
Type: Math.Gmp.Nativechar_ptr
The source string.
base
Type: SystemInt32
The base,

Return Value

Type: Int32
The return value is 0 if the entire string is a valid number, or -1 if not.
Remarks

The string can be an integer like "41" or a fraction like "41/152". The fraction must be in canonical form (see GNU MP - Rational Number Functions), or if not then mpq_canonicalize must be called.

The numerator and optional denominator are parsed the same as in mpz_set_str (see GNU MP - Assigning Integers). White space is allowed in the string, and is simply ignored. The base can vary from 2 to 62, or if base is 0 then the leading characters are used: 0x or 0X for hex, 0b or 0B for binary, 0 for octal, or decimal otherwise. Note that this is done separately for the numerator and denominator, so for instance 0xEF/100 is 239/100, whereas 0xEF/0x100 is 239/256.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational x.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Set the value of x.
char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321 / 234 567 890");
gmp_lib.mpq_set_str(x, value, 10);

// Assert the value of x.
char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", ""));

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpq_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_swap


gmp_lib.mpq_set_ui Method

gmp_libmpq_set_ui Method
Set the value of rop to op1 / op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_ui(
    mpq_t rop,
    uint op1,
    uint op2
)
Public Shared Sub mpq_set_ui (
    rop As mpq_t,
    op1 As UInteger,
    op2 As UInteger
)
public:
static void mpq_set_ui(
    mpq_t^ rop,
    unsigned int op1,
    unsigned int op2
)
static member mpq_set_ui :
        rop : mpq_t *
        op1 : uint32 *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op1
Type: SystemUInt32
The first operand rational.
op2
Type: SystemUInt32
The second operand rational.
Remarks

Note that if op1 and op2 have common factors, rop has to be passed to mpq_canonicalize before any operations are performed on rop.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new rational x.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);

// Set the value of x to 10 / 11.
gmp_lib.mpq_set_ui(x, 10U, 11U);

// Assert that the value of x is 10 / 11.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(x, 10U, 11U) == 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpq_clear(x);
' Create and initialize a new rational x.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)

' Set the value of x to 10 / 11.
gmp_lib.mpq_set_ui(x, 10UI, 11UI)

' Assert that the value of x is 10 / 11.
Assert.IsTrue(gmp_lib.mpq_cmp_ui(x, 10UI, 11UI) = 0)

' Release unmanaged memory allocated for x.
gmp_lib.mpq_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_set_z Method

gmp_libmpq_set_z Method
Assign rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_set_z(
    mpq_t rop,
    mpz_t op
)
Public Shared Sub mpq_set_z (
    rop As mpq_t,
    op As mpz_t
)
public:
static void mpq_set_z(
    mpq_t^ rop,
    mpz_t^ op
)
static member mpq_set_z :
        rop : mpq_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempq_t
The result rational.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11);

// Create, initialize, and set a new integer y to -210.
mpz_t y = new mpz_t();
gmp_lib.mpz_init(y);
gmp_lib.mpz_set_si(y, -210);

// Assign the value of y to x.
gmp_lib.mpq_set_z(x, y);

// Assert that the value of x is -210 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clear(x);
gmp_lib.mpz_clear(y);
' Create, initialize, and set a new rational x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11)

' Create, initialize, and set a new integer y to -210.
Dim y As New mpz_t()
gmp_lib.mpz_init(y)
gmp_lib.mpz_set_si(y, -210)

' Assign the value of y to x.
gmp_lib.mpq_set_z(x, y)

' Assert that the value of x is -210 / 1.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) = 0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clear(x)
gmp_lib.mpz_clear(y)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_ui
mpq_set_si
mpq_set_str
mpq_swap


gmp_lib.mpq_sgn Method

gmp_libmpq_sgn Method
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpq_sgn(
    mpq_t op
)
Public Shared Function mpq_sgn (
    op As mpq_t
) As Integer
public:
static int mpq_sgn(
    mpq_t^ op
)
static member mpq_sgn :
        op : mpq_t -> int

Parameters

op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

Type: Int32
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational x to -10 / 11.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -10, 11);

// Assert that op is negative.
Assert.IsTrue(gmp_lib.mpq_sgn(op) == -1);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clear(op);
' Create, initialize, and set a new rational x to -10 / 11.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -10, 11)

' Assert that op is negative.
Assert.IsTrue(gmp_lib.mpq_sgn(op) = -1)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_cmp
mpq_cmp_z
mpq_cmp_ui
mpq_cmp_si
mpq_equal


gmp_lib.mpq_sub Method

gmp_libmpq_sub Method
Set difference to minuend - subtrahend.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_sub(
    mpq_t difference,
    mpq_t minuend,
    mpq_t subtrahend
)
Public Shared Sub mpq_sub (
    difference As mpq_t,
    minuend As mpq_t,
    subtrahend As mpq_t
)
public:
static void mpq_sub(
    mpq_t^ difference,
    mpq_t^ minuend,
    mpq_t^ subtrahend
)
static member mpq_sub :
        difference : mpq_t *
        minuend : mpq_t *
        subtrahend : mpq_t -> unit

Parameters

difference
Type: Math.Gmp.Nativempq_t
The result rational.
minuend
Type: Math.Gmp.Nativempq_t
The first operand rational.
subtrahend
Type: Math.Gmp.Nativempq_t
The second operand rational.
Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpq_add
mpq_mul
mpq_mul_2exp
mpq_div
mpq_div_2exp
mpq_neg
mpq_abs
mpq_inv


gmp_lib.mpq_swap Method

gmp_libmpq_swap Method
Swap the values rop1 and rop2 efficiently.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpq_swap(
    mpq_t rop1,
    mpq_t rop2
)
Public Shared Sub mpq_swap (
    rop1 As mpq_t,
    rop2 As mpq_t
)
public:
static void mpq_swap(
    mpq_t^ rop1,
    mpq_t^ rop2
)
static member mpq_swap :
        rop1 : mpq_t *
        rop2 : mpq_t -> unit

Parameters

rop1
Type: Math.Gmp.Nativempq_t
The first rational.
rop2
Type: Math.Gmp.Nativempq_t
The second rational.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new rational x to 10 / 11.
mpq_t x = new mpq_t();
gmp_lib.mpq_init(x);
gmp_lib.mpq_set_si(x, 10, 11U);

// Create, initialize, and set a new rational x to -210 / 13.
mpq_t y = new mpq_t();
gmp_lib.mpq_init(y);
gmp_lib.mpq_set_si(y, -210, 13U);

// Swap the values of x and y.
gmp_lib.mpq_swap(x, y);

// Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13U) == 0);
Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11U) == 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, null);
' Create, initialize, and set a new rational x to 10 / 11.
Dim x As New mpq_t()
gmp_lib.mpq_init(x)
gmp_lib.mpq_set_si(x, 10, 11UI)

' Create, initialize, and set a new rational x to -210 / 13.
Dim y As New mpq_t()
gmp_lib.mpq_init(y)
gmp_lib.mpq_set_si(y, -210, 13UI)

' Swap the values of x and y.
gmp_lib.mpq_swap(x, y)

' Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13UI) = 0)
Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11UI) = 0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpq_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpq_canonicalize
mpq_init
mpq_inits
mpq_clear
mpq_clears
mpq_set
mpq_set_z
mpq_set_ui
mpq_set_si
mpq_set_str


gmp_lib.mpz_2fac_ui Method

gmp_libmpz_2fac_ui Method
Set rop to the double-factorial n!!.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_2fac_ui(
    mpz_t rop,
    uint n
)
Public Shared Sub mpz_2fac_ui (
    rop As mpz_t,
    n As UInteger
)
public:
static void mpz_2fac_ui(
    mpz_t^ rop,
    unsigned int n
)
static member mpz_2fac_ui :
        rop : mpz_t *
        n : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: SystemUInt32
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = 9!!.
gmp_lib.mpz_2fac_ui(rop, 9U);

// Assert that rop is 945.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 945);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = 9!!.
gmp_lib.mpz_2fac_ui(rop, 9UI)

' Assert that rop is 945.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 945)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fac_ui
mpz_mfac_uiui


gmp_lib.mpz_abs Method

gmp_libmpz_abs Method
Set rop to the absolute value of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_abs(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_abs (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_abs(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_abs :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = |x|.
gmp_lib.mpz_abs(z, x);

// Assert that z is |x|.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = |x|.
gmp_lib.mpz_abs(z, x)

' Assert that z is |x|.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_add Method

gmp_libmpz_add Method
Set rop to op1 + op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_add(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_add (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_add(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_add :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 12222.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 12222U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x + y.
gmp_lib.mpz_add(z, x, y);

// Assert that z is the sum of x and y.
Assert.IsTrue(gmp_lib.mpz_get_ui(z) == 22222U);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 12222.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 12222UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x + y.
gmp_lib.mpz_add(z, x, y)

' Assert that z is the sum of x and y.
Assert.IsTrue(gmp_lib.mpz_get_ui(z) = 22222UI)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add_ui
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_add_ui Method

gmp_libmpz_add_ui Method
Set rop to op1 + op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_add_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_add_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_add_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_add_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 0.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Increment x twice by 101999.
gmp_lib.mpz_add_ui(x, x, 101999U);
gmp_lib.mpz_add_ui(x, x, 101999U);

// Assert that x is 203998.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 203998U);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 0.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Increment x twice by 101999.
gmp_lib.mpz_add_ui(x, x, 101999UI)
gmp_lib.mpz_add_ui(x, x, 101999UI)

' Assert that x is 203998.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 203998UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_addmul Method

gmp_libmpz_addmul Method
Set rop to rop + op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_addmul(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_addmul (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_addmul(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_addmul :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 12222.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 12222U);

// Create, initialize, and set the value of z to 20000.
mpz_t z = new mpz_t();
gmp_lib.mpz_init_set_ui(z, 20000U);

// Set z += x * y.
gmp_lib.mpz_addmul(z, x, y);

// Assert that z has been incremented by 10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000U + 10000 * 12222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 12222.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 12222UI)

' Create, initialize, and set the value of z to 20000.
Dim z As New mpz_t()
gmp_lib.mpz_init_set_ui(z, 20000UI)

' Set z += x * y.
gmp_lib.mpz_addmul(z, x, y)

' Assert that z has been incremented by 10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000UI + 10000 * 12222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul_ui
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_addmul_ui Method

gmp_libmpz_addmul_ui Method
Set rop to rop + op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_addmul_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_addmul_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_addmul_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_addmul_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 20000.
mpz_t z = new mpz_t();
gmp_lib.mpz_init_set_si(z, 20000);

// Set z += x * 12222.
gmp_lib.mpz_addmul_ui(z, x, 12222U);

// Assert that z has been incremented by -10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 + -10000 * 12222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 20000.
Dim z As New mpz_t()
gmp_lib.mpz_init_set_si(z, 20000)

' Set z += x * 12222.
gmp_lib.mpz_addmul_ui(z, x, 12222UI)

' Assert that z has been incremented by -10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 + -10000 * 12222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_and Method

gmp_libmpz_and Method
Set rop to op1 bitwise-and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_and(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_and (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_and(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_and :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the bitwise and of op1 and op2.
gmp_lib.mpz_and(rop, op1, op2);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the bitwise and of op1 and op2.
gmp_lib.mpz_and(rop, op1, op2)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_bin_ui Method

gmp_libmpz_bin_ui Method
Compute the binomial coefficient n over k and store the result in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_bin_ui(
    mpz_t rop,
    mpz_t n,
    uint k
)
Public Shared Sub mpz_bin_ui (
    rop As mpz_t,
    n As mpz_t,
    k As UInteger
)
public:
static void mpz_bin_ui(
    mpz_t^ rop,
    mpz_t^ n,
    unsigned int k
)
static member mpz_bin_ui :
        rop : mpz_t *
        n : mpz_t *
        k : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: Math.Gmp.Nativempz_t
The first operand integer.
k
Type: SystemUInt32
The second operand integer.
Remarks

Negative values of n are supported by mpz_bin_ui, using the identity bin(-n, k) = (-1)^k * bin(n + k - 1, k), see Knuth volume 1 section 1.2.6 part G.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 4.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 4);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the binomial coefficient (n:2).
gmp_lib.mpz_bin_ui(rop, n, 2U);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for n and rop.
gmp_lib.mpz_clears(n, rop, null);
' Create, initialize, and set the value of n to 4.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 4)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the binomial coefficient (n:2).
gmp_lib.mpz_bin_ui(rop, n, 2UI)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for n and rop.
gmp_lib.mpz_clears(n, rop, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_bin_uiui


gmp_lib.mpz_bin_uiui Method

gmp_libmpz_bin_uiui Method
Compute the binomial coefficient n over k and store the result in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_bin_uiui(
    mpz_t rop,
    uint n,
    uint k
)
Public Shared Sub mpz_bin_uiui (
    rop As mpz_t,
    n As UInteger,
    k As UInteger
)
public:
static void mpz_bin_uiui(
    mpz_t^ rop,
    unsigned int n,
    unsigned int k
)
static member mpz_bin_uiui :
        rop : mpz_t *
        n : uint32 *
        k : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: SystemUInt32
The first operand integer.
k
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the binomial coefficient (4:2).
gmp_lib.mpz_bin_uiui(rop, 4U, 2U);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the binomial coefficient (4:2).
gmp_lib.mpz_bin_uiui(rop, 4UI, 2UI)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_bin_ui


gmp_lib.mpz_cdiv_q Method

gmp_libmpz_cdiv_q Method
Set the quotient q to ceiling(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_cdiv_q(
    mpz_t q,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_cdiv_q (
    q As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_cdiv_q(
    mpz_t^ q,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_cdiv_q :
        q : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = ceiling(n / d).
gmp_lib.mpz_cdiv_q(q, n, d);

// Assert that q is ceiling(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);

// Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = ceiling(n / d).
gmp_lib.mpz_cdiv_q(q, n, d)

' Assert that q is ceiling(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334)

' Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_q_2exp Method

gmp_libmpz_cdiv_q_2exp Method
Set the quotient q to ceiling(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_cdiv_q_2exp(
    mpz_t q,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_cdiv_q_2exp (
    q As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_cdiv_q_2exp(
    mpz_t^ q,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_cdiv_q_2exp :
        q : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = ceiling(n / 2^2).
gmp_lib.mpz_cdiv_q_2exp(q, n, 2U);

// Assert that q is ceiling(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2501);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = ceiling(n / 2^2).
gmp_lib.mpz_cdiv_q_2exp(q, n, 2UI)

' Assert that q is ceiling(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2501)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_q_ui Method

gmp_libmpz_cdiv_q_ui Method
Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_cdiv_q_ui(
    mpz_t q,
    mpz_t n,
    uint d
)
Public Shared Function mpz_cdiv_q_ui (
    q As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_cdiv_q_ui(
    mpz_t^ q,
    mpz_t^ n,
    unsigned int d
)
static member mpz_cdiv_q_ui :
        q : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return the remainder r = | n - q * d |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = ceiling(n / 3) and return r = n - 3 * q.
// Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3U) == 2U);
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = ceiling(n / 3) and return r = n - 3 * q.
' Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3UI) = 2UI)
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_qr Method

gmp_libmpz_cdiv_qr Method
Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_cdiv_qr(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_cdiv_qr (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_cdiv_qr(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_cdiv_qr :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = ceiling(n / 3) and r = n - d * q.
gmp_lib.mpz_cdiv_qr(q, r, n, d);

// Assert that q is 3334, and that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);

// Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

 Set q = ceiling(n / 3) and r = n - d * q.
gmp_lib.mpz_cdiv_qr(q, r, n, d)

' Assert that q is 3334, and that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2)

' Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_qr_ui Method

gmp_libmpz_cdiv_qr_ui Method
Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_cdiv_qr_ui(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_cdiv_qr_ui (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_cdiv_qr_ui(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_cdiv_qr_ui :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = ceiling(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3U) == 2U);

// Assert that q is 3334, and that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);

// Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

' Set q = ceiling(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3UI) = 2UI)

' Assert that q is 3334, and that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2)

' Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_r Method

gmp_libmpz_cdiv_r Method
Set the remainder r to n - q * d where q = ceiling(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_cdiv_r(
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_cdiv_r (
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_cdiv_r(
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_cdiv_r :
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - d * ceiling(n / d).
gmp_lib.mpz_cdiv_r(r, n, d);

// Assert that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);

// Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - d * ceiling(n / d).
gmp_lib.mpz_cdiv_r(r, n, d)

' Assert that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2)

' Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_r_2exp Method

gmp_libmpz_cdiv_r_2exp Method
Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_cdiv_r_2exp(
    mpz_t r,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_cdiv_r_2exp (
    r As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_cdiv_r_2exp(
    mpz_t^ r,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_cdiv_r_2exp :
        r : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 2^2 * ceiling(n / 2^2)
gmp_lib.mpz_cdiv_r_2exp(r, n, 2U);

// Assert that r is -3.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -3);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)
' Set r = n - 2^2 * ceiling(n / 2^2)
gmp_lib.mpz_cdiv_r_2exp(r, n, 2UI)

' Assert that r is -3.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = -3)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_r_ui Method

gmp_libmpz_cdiv_r_ui Method
Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_cdiv_r_ui(
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_cdiv_r_ui (
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_cdiv_r_ui(
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_cdiv_r_ui :
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 3 * ceiling(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_cdiv_r_ui(r, n, 3U) == 2U);

// Assert that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - 3 * ceiling(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_cdiv_r_ui(r, n, 3UI) = 2UI)

' Assert that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_qr_ui
mpz_cdiv_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_cdiv_ui Method

gmp_libmpz_cdiv_ui Method
Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_cdiv_ui(
    mpz_t n,
    uint d
)
Public Shared Function mpz_cdiv_ui (
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_cdiv_ui(
    mpz_t^ n,
    unsigned int d
)
static member mpz_cdiv_ui :
        n : mpz_t *
        d : uint32 -> uint32

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
The remainder | r | where r = n - q * d, and where q = ceiling(n / d).
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Assert that returned value is |n - 3 * ceiling(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3U) == 2U);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Assert that returned value is |n - 3 * ceiling(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3UI) = 2UI)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_q
mpz_cdiv_r
mpz_cdiv_qr
mpz_cdiv_q_ui
mpz_cdiv_r_ui
mpz_cdiv_qr_ui
mpz_cdiv_q_2exp
mpz_cdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_clear Method

gmp_libmpz_clear Method
Free the space occupied by x.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_clear(
    mpz_t x
)
Public Shared Sub mpz_clear (
    x As mpz_t
)
public:
static void mpz_clear(
    mpz_t^ x
)
static member mpz_clear :
        x : mpz_t -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.
Remarks

Call this function for all mpz_t variables when you are done with them.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Assert that the value of x is 0.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 0U);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create and initialize a new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Assert that the value of x is 0.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 0UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clears
mpz_init
mpz_inits
mpz_init2
mpz_realloc2


gmp_lib.mpz_clears Method

gmp_libmpz_clears Method
Free the space occupied by a NULL-terminated list of mpz_t variables.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_clears(
    params mpz_t[] x
)
Public Shared Sub mpz_clears (
    ParamArray x As mpz_t()
)
public:
static void mpz_clears(
    ... array<mpz_t^>^ x
)
static member mpz_clears :
        x : mpz_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
A NULL-terminated list of mpz_t variables.
Examples
C#
VB
C++
F#
Copy
// Create new integers x1, x2 and x3.
mpz_t x1 = new mpz_t();
mpz_t x2 = new mpz_t();
mpz_t x3 = new mpz_t();

// Initialize the integers.
gmp_lib.mpz_inits(x1, x2, x3, null);

// Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0);
Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0);
Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0);

// Release unmanaged memory allocated for the integers.
gmp_lib.mpz_clears(x1, x2, x3, null);
' Create new integers x1, x2 and x3.
Dim x1 As New mpz_t()
Dim x2 As New mpz_t()
Dim x3 As New mpz_t()

' Initialize the integers.
gmp_lib.mpz_inits(x1, x2, x3, Nothing)

' Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x1) = 0)
Assert.IsTrue(gmp_lib.mpz_get_si(x2) = 0)
Assert.IsTrue(gmp_lib.mpz_get_si(x3) = 0)

' Release unmanaged memory allocated for the integers.
gmp_lib.mpz_clears(x1, x2, x3, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clear
mpz_init
mpz_inits
mpz_init2
mpz_realloc2


gmp_lib.mpz_clrbit Method

gmp_libmpz_clrbit Method
Clear bit bit_index in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_clrbit(
    mpz_t rop,
    mp_bitcnt_t bit_index
)
Public Shared Sub mpz_clrbit (
    rop As mpz_t,
    bit_index As mp_bitcnt_t
)
public:
static void mpz_clrbit(
    mpz_t^ rop,
    mp_bitcnt_t bit_index
)
static member mpz_clrbit :
        rop : mpz_t *
        bit_index : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
bit_index
Type: Math.Gmp.Nativemp_bitcnt_t
The index of the bit to clear.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 70.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init_set_si(rop, 70);

// Clear bit 3 of rop.
gmp_lib.mpz_clrbit(rop, 3U);

// Assert that rop is 70.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 70);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 70.
Dim rop As New mpz_t()
gmp_lib.mpz_init_set_si(rop, 70)

' Clear bit 3 of rop.
gmp_lib.mpz_clrbit(rop, 3UI)

' Assert that rop is 70.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 70)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_cmp Method

gmp_libmpz_cmp Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmp(
    mpz_t op1,
    mpz_t op2
)
Public Shared Function mpz_cmp (
    op1 As mpz_t,
    op2 As mpz_t
) As Integer
public:
static int mpz_cmp(
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_cmp :
        op1 : mpz_t *
        op2 : mpz_t -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, or a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Assert that op1 < op2.
Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Assert that op1 < op2.
Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp_d
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_d
mpz_cmpabs_ui
mpz_sgn


gmp_lib.mpz_cmp_d Method

gmp_libmpz_cmp_d Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmp_d(
    mpz_t op1,
    double op2
)
Public Shared Function mpz_cmp_d (
    op1 As mpz_t,
    op2 As Double
) As Integer
public:
static int mpz_cmp_d(
    mpz_t^ op1,
    double op2
)
static member mpz_cmp_d :
        op1 : mpz_t *
        op2 : float -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemDouble
The second operand integer.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, or a negative value if op1 < op2.
Remarks

mpz_cmp_d can be called with an infinity (see double.PositiveInfinity or double.NegativeInfinity), but results are undefined for a double.NaN.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Assert that op1 < 70.0.
Assert.IsTrue(gmp_lib.mpz_cmp_d(op1, 70.0) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Assert that op1 < 70.0.
Assert.IsTrue(gmp_lib.mpz_cmp_d(op1, 70.0) < 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_d
mpz_cmpabs_ui
mpz_sgn


gmp_lib.mpz_cmp_si Method

gmp_libmpz_cmp_si Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmp_si(
    mpz_t op1,
    int op2
)
Public Shared Function mpz_cmp_si (
    op1 As mpz_t,
    op2 As Integer
) As Integer
public:
static int mpz_cmp_si(
    mpz_t^ op1,
    int op2
)
static member mpz_cmp_si :
        op1 : mpz_t *
        op2 : int -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemInt32
The second operand integer.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, or a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Assert that op1 < 70.
Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Assert that op1 < 70.
Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_d
mpz_cmpabs_ui
mpz_sgn


gmp_lib.mpz_cmp_ui Method

gmp_libmpz_cmp_ui Method
Compare op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmp_ui(
    mpz_t op1,
    uint op2
)
Public Shared Function mpz_cmp_ui (
    op1 As mpz_t,
    op2 As UInteger
) As Integer
public:
static int mpz_cmp_ui(
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_cmp_ui :
        op1 : mpz_t *
        op2 : uint32 -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, or a negative value if op1 < op2.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Assert that op1 < 70.
Assert.IsTrue(gmp_lib.mpz_cmp_ui(op1, 70U) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Assert that op1 < 70.
Assert.IsTrue(gmp_lib.mpz_cmp_ui(op1, 70UI) < 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_si
mpz_cmpabs
mpz_cmpabs_d
mpz_sgn


gmp_lib.mpz_cmpabs Method

gmp_libmpz_cmpabs Method
Compare the absolute values of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmpabs(
    mpz_t op1,
    mpz_t op2
)
Public Shared Function mpz_cmpabs (
    op1 As mpz_t,
    op2 As mpz_t
) As Integer
public:
static int mpz_cmpabs(
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_cmpabs :
        op1 : mpz_t *
        op2 : mpz_t -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
Return a positive value if | op1 | > | op2 |, zero if | op1 | = | op2 |, or a negative value if | op1 | < | op2 |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to -63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_si(op1, -63);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Assert that |op1| < |op2|.
Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, null);
' Create, initialize, and set the value of op1 to -63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_si(op1, -63)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Assert that |op1| < |op2|.
Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs_d
mpz_cmpabs_ui
mpz_sgn


gmp_lib.mpz_cmpabs_d Method

gmp_libmpz_cmpabs_d Method
Compare the absolute values of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmpabs_d(
    mpz_t op1,
    double op2
)
Public Shared Function mpz_cmpabs_d (
    op1 As mpz_t,
    op2 As Double
) As Integer
public:
static int mpz_cmpabs_d(
    mpz_t^ op1,
    double op2
)
static member mpz_cmpabs_d :
        op1 : mpz_t *
        op2 : float -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemDouble
The second operand integer.

Return Value

Type: Int32
Return a positive value if | op1 | > | op2 |, zero if | op1 | = | op2 |, or a negative value if | op1 | < | op2 |.
Remarks

mpz_cmpabs_d can be called with an infinity (see double.PositiveInfinity or double.NegativeInfinity), but results are undefined for a double.NaN.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to -63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_si(op1, -63);

// Assert that |op1| < |-70.0|.
Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
' Create, initialize, and set the value of op1 to -63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_si(op1, -63)

' Assert that |op1| < |-70.0|.
Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0)

' Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_ui
mpz_sgn


gmp_lib.mpz_cmpabs_ui Method

gmp_libmpz_cmpabs_ui Method
Compare the absolute values of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_cmpabs_ui(
    mpz_t op1,
    uint op2
)
Public Shared Function mpz_cmpabs_ui (
    op1 As mpz_t,
    op2 As UInteger
) As Integer
public:
static int mpz_cmpabs_ui(
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_cmpabs_ui :
        op1 : mpz_t *
        op2 : uint32 -> int

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.

Return Value

Type: Int32
Return a positive value if | op1 | > | op2 |, zero if | op1 | = | op2 |, or a negative value if | op1 | < | op2 |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to -63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_si(op1, -63);

// Assert that |op1| < |70|.
Assert.IsTrue(gmp_lib.mpz_cmpabs_ui(op1, 70U) < 0);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_d
mpz_sgn


gmp_lib.mpz_com Method

gmp_libmpz_com Method
Set rop to the one’s complement of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_com(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_com (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_com(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_com :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 63.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 63U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the one's complement of op.
gmp_lib.mpz_com(rop, op);

// Assert that rop is -64.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == -64);

// Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of op to 63.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 63UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the one's complement of op.
gmp_lib.mpz_com(rop, op)

' Assert that rop is -64.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = -64)

' Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_combit Method

gmp_libmpz_combit Method
Complement bit bit_index in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_combit(
    mpz_t rop,
    mp_bitcnt_t bit_index
)
Public Shared Sub mpz_combit (
    rop As mpz_t,
    bit_index As mp_bitcnt_t
)
public:
static void mpz_combit(
    mpz_t^ rop,
    mp_bitcnt_t bit_index
)
static member mpz_combit :
        rop : mpz_t *
        bit_index : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
bit_index
Type: Math.Gmp.Nativemp_bitcnt_t
The index of the bit to comlpement.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 70.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init_set_si(rop, 70);

// Complement bit 3 of rop.
gmp_lib.mpz_combit(rop, 3U);

// Assert that rop is 78.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 70.
Dim rop As New mpz_t()
gmp_lib.mpz_init_set_si(rop, 70)

' Complement bit 3 of rop.
gmp_lib.mpz_combit(rop, 3UI)

' Assert that rop is 78.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 78)

' Release unmanaged memory allocated for rop.

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_tstbit


gmp_lib.mpz_congruent_2exp_p Method

gmp_libmpz_congruent_2exp_p Method
Return non-zero if n is congruent to c modulo 2^b.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_congruent_2exp_p(
    mpz_t n,
    mpz_t c,
    mp_bitcnt_t b
)
Public Shared Function mpz_congruent_2exp_p (
    n As mpz_t,
    c As mpz_t,
    b As mp_bitcnt_t
) As Integer
public:
static int mpz_congruent_2exp_p(
    mpz_t^ n,
    mpz_t^ c,
    mp_bitcnt_t b
)
static member mpz_congruent_2exp_p :
        n : mpz_t *
        c : mpz_t *
        b : mp_bitcnt_t -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
An operand integer.
c
Type: Math.Gmp.Nativempz_t
The remainder of the division by 2^b.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two divisor.

Return Value

Type: Int32
Non-zero if n is congruent to c modulo 2^b.
Remarks

n is congruent to c mod 2^b if there exists an integer q satisfying n = c + q * 2^b.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_ui(n, 10001U);

// Create, initialize, and set the value of b to 1.
mpz_t c = new mpz_t();
gmp_lib.mpz_init_set_ui(c, 1U);

// Assert that n is congruent to c mod 2^3.
Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3U) > 0);

// Release unmanaged memory allocated for n and c.
gmp_lib.mpz_clears(n, c, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 10001UI)

' Create, initialize, and set the value of b to 1.
Dim c As New mpz_t()
gmp_lib.mpz_init_set_ui(c, 1UI)

' Assert that n is congruent to c mod 2^3.
Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3UI) > 0)

' Release unmanaged memory allocated for n and c.
gmp_lib.mpz_clears(n, c, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_congruent_ui_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_congruent_p Method

gmp_libmpz_congruent_p Method
Return non-zero if n is congruent to c modulo d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_congruent_p(
    mpz_t n,
    mpz_t c,
    mpz_t d
)
Public Shared Function mpz_congruent_p (
    n As mpz_t,
    c As mpz_t,
    d As mpz_t
) As Integer
public:
static int mpz_congruent_p(
    mpz_t^ n,
    mpz_t^ c,
    mpz_t^ d
)
static member mpz_congruent_p :
        n : mpz_t *
        c : mpz_t *
        d : mpz_t -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
An operand integer.
c
Type: Math.Gmp.Nativempz_t
The remainder of the division by d.
d
Type: Math.Gmp.Nativempz_t
The divisor operand integer.

Return Value

Type: Int32
Non-zero if n is congruent to c modulo d.
Remarks

n is congruent to c mod d if there exists an integer q satisfying n = c + q * d. Unlike the other division functions, d = 0 is accepted and following the rule it can be seen that n and c are considered congruent mod 0 only when exactly equal.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_ui(n, 10000U);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_ui(d, 3U);

// Create, initialize, and set the value of c to 1.
mpz_t c = new mpz_t();
gmp_lib.mpz_init_set_ui(c, 1U);

// Assert that n is congruent to c mod d.
Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0);

// Release unmanaged memory allocated for n, d, and c.
gmp_lib.mpz_clears(n, d, c, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 10000UI)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_ui(d, 3UI)

' Create, initialize, and set the value of c to 1.
Dim c As New mpz_t()
gmp_lib.mpz_init_set_ui(c, 1UI)

' Assert that n is congruent to c mod d.
Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0)

' Release unmanaged memory allocated for n, d, and c.
gmp_lib.mpz_clears(n, d, c, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_2exp_p
mpz_congruent_ui_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_congruent_ui_p Method

gmp_libmpz_congruent_ui_p Method
Return non-zero if n is congruent to c modulo d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_congruent_ui_p(
    mpz_t n,
    uint c,
    uint d
)
Public Shared Function mpz_congruent_ui_p (
    n As mpz_t,
    c As UInteger,
    d As UInteger
) As Integer
public:
static int mpz_congruent_ui_p(
    mpz_t^ n,
    unsigned int c,
    unsigned int d
)
static member mpz_congruent_ui_p :
        n : mpz_t *
        c : uint32 *
        d : uint32 -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
An operand integer.
c
Type: SystemUInt32
The remainder of the division by d.
d
Type: SystemUInt32
The divisor operand integer.

Return Value

Type: Int32
Non-zero if n is congruent to c modulo d.
Remarks

n is congruent to c mod d if there exists an integer q satisfying n = c + q * d. Unlike the other division functions, d = 0 is accepted and following the rule it can be seen that n and c are considered congruent mod 0 only when exactly equal.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_ui(n, 10000U);

// Assert that n is congruent to 1 mod 3.
Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1U, 3U) > 0);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 10000UI)

' Assert that n is congruent to 1 mod 3.
Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1UI, 3UI) > 0)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_2exp_p
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_divexact Method

gmp_libmpz_divexact Method
Set q to n / d when it is known in advance that d divides n.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_divexact(
    mpz_t q,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_divexact (
    q As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_divexact(
    mpz_t^ q,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_divexact :
        q : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 5.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 5U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x / y.
gmp_lib.mpz_divexact(z, x, y);

// Assert that z is 2000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 5.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 5UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x / y.
gmp_lib.mpz_divexact(z, x, y)

' Assert that z is 2000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2000)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact_ui
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_divexact_ui Method

gmp_libmpz_divexact_ui Method
Set q to n / d when it is known in advance that d divides n.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_divexact_ui(
    mpz_t q,
    mpz_t n,
    uint d
)
Public Shared Sub mpz_divexact_ui (
    q As mpz_t,
    n As mpz_t,
    d As UInteger
)
public:
static void mpz_divexact_ui(
    mpz_t^ q,
    mpz_t^ n,
    unsigned int d
)
static member mpz_divexact_ui :
        q : mpz_t *
        n : mpz_t *
        d : uint32 -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x / 5.
gmp_lib.mpz_divexact_ui(z, x, 5U);

// Assert that z is 2000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x / 5.
gmp_lib.mpz_divexact_ui(z, x, 5UI)

' Assert that z is 2000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2000)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_divisible_2exp_p Method

gmp_libmpz_divisible_2exp_p Method
Return non-zero if n is exactly divisible by 2^b.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_divisible_2exp_p(
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Function mpz_divisible_2exp_p (
    n As mpz_t,
    b As mp_bitcnt_t
) As Integer
public:
static int mpz_divisible_2exp_p(
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_divisible_2exp_p :
        n : mpz_t *
        b : mp_bitcnt_t -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator integer.

Return Value

Type: Int32
Non-zero if n is exactly divisible by 2^b.
Remarks

n is divisible by 2^b if there exists an integer q satisfying n = q * 2^b.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2U) > 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2UI) > 0)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_divisible_ui_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_divisible_p Method

gmp_libmpz_divisible_p Method
Return non-zero if n is exactly divisible by d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_divisible_p(
    mpz_t n,
    mpz_t d
)
Public Shared Function mpz_divisible_p (
    n As mpz_t,
    d As mpz_t
) As Integer
public:
static int mpz_divisible_p(
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_divisible_p :
        n : mpz_t *
        d : mpz_t -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.

Return Value

Type: Int32
Non-zero if n is exactly divisible by d.
Remarks

n is divisible by d if there exists an integer q satisfying n = q * d. Unlike the other division functions, d = 0 is accepted and following the rule it can be seen that only 0 is considered divisible by 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 5.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 5U);

// Assert that x is divisible by y.
Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 5.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 5UI)

' Assert that x is divisible by y.
Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_2exp_p
mpz_divisible_ui_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_divisible_ui_p Method

gmp_libmpz_divisible_ui_p Method
Return non-zero if n is exactly divisible by d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_divisible_ui_p(
    mpz_t n,
    uint d
)
Public Shared Function mpz_divisible_ui_p (
    n As mpz_t,
    d As UInteger
) As Integer
public:
static int mpz_divisible_ui_p(
    mpz_t^ n,
    unsigned int d
)
static member mpz_divisible_ui_p :
        n : mpz_t *
        d : uint32 -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: Int32
Non-zero if n is exactly divisible by d.
Remarks

n is divisible by d if there exists an integer q satisfying n = q * d. Unlike the other division functions, d = 0 is accepted and following the rule it can be seen that only 0 is considered divisible by 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Assert that x is divisible by 5.
Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5U) > 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Assert that x is divisible by 5.
Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5UI) > 0)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_2exp_p
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_even_p Method

gmp_libmpz_even_p Method
Determine whether op is even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_even_p(
    mpz_t op
)
Public Shared Function mpz_even_p (
    op As mpz_t
) As Integer
public:
static int mpz_even_p(
    mpz_t^ op
)
static member mpz_even_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero if even, zero if odd.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 427295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 427295);

// Assert that op is not even but odd.
Assert.IsTrue(gmp_lib.mpz_even_p(op) == 0);
Assert.IsTrue(gmp_lib.mpz_odd_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 427295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 427295)

' Assert that op is not even but odd.
Assert.IsTrue(gmp_lib.mpz_even_p(op) = 0)
Assert.IsTrue(gmp_lib.mpz_odd_p(op) > 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_sizeinbase


gmp_lib.mpz_export Method

gmp_libmpz_export Method
Overload List
Name | Description
mpz_export(void_ptr, ptrsize_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
mpz_export(void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t) | Fill rop with word data from op.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpz_export Method (void_ptr, ptr(size_t), Int32, size_t, Int32, size_t, mpz_t)

gmp_libmpz_export Method (void_ptr, ptrsize_t, Int32, size_t, Int32, size_t, mpz_t)
Fill rop with word data from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void_ptr mpz_export(
    void_ptr rop,
    ptr<size_t> countp,
    int order,
    size_t size,
    int endian,
    size_t nails,
    mpz_t op
)
Public Shared Function mpz_export (
    rop As void_ptr,
    countp As ptr(Of size_t),
    order As Integer,
    size As size_t,
    endian As Integer,
    nails As size_t,
    op As mpz_t
) As void_ptr
public:
static void_ptr mpz_export(
    void_ptr rop,
    ptr<size_t>^ countp,
    int order,
    size_t size,
    int endian,
    size_t nails,
    mpz_t^ op
)
static member mpz_export :
        rop : void_ptr *
        countp : ptr<size_t> *
        order : int *
        size : size_t *
        endian : int *
        nails : size_t *
        op : mpz_t -> void_ptr

Parameters

rop
Type: Math.Gmp.Nativevoid_ptr
The result integer.
countp
Type: Math.Gmp.Nativeptr size_t
The number of words produced.
order
Type: SystemInt32
1 for most significant word first or -1 for least significant first.
size
Type: Math.Gmp.Nativesize_t
The number of bytes in each word.
endian
Type: SystemInt32
1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU.
nails
Type: Math.Gmp.Nativesize_t
The number of most significant bits to skip.
op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: void_ptr
Either rop or the allocated block.
Remarks

The parameters specify the format of the data produced. Each word will be size bytes and order can be 1 for most significant word first or -1 for least significant first. Within each word endian can be 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. The most significant nails bits of each word are unused and set to zero, this can be 0 to produce full words.

The number of words produced is written to countp, or countp can be NULL to discard the count. rop must have enough space for the data, or if rop is NULL then a result array of the necessary size is allocated using the current GMP allocation function (see GNU MP - Custom Allocation). In either case the return value is the destination used, either rop or the allocated block.

If op is non-zero then the most significant word produced will be non-zero. If op is zero then the count returned will be zero and nothing written to rop. If rop is NULL in this case, no block is allocated, just NULL is returned.

The sign of op is ignored, just the absolute value is exported. An application can use mpz_sgn to get the sign and handle it as desired. (see GNU MP - Integer Comparisons)

There are no data alignment restrictions on rop, any address is allowed.

When an application is allocating space itself the required size can be determined with a calculation like the following. Since mpz_sizeinbase always returns at least 1, count here will be at least one, which avoids any portability problems with malloc(0), though if z is zero no space at all is actually needed (or written).

C++
Copy
numb = 8 * size - nail;
count = (mpz_sizeinbase(z, 2) + numb - 1) / numb;
p = malloc(count * size);
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 0x800000000000000000000001.
mpz_t op = new mpz_t();
char_ptr value = new char_ptr("800000000000000000000001");
gmp_lib.mpz_init_set_str(op, value, 16);

// Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
void_ptr data = gmp_lib.allocate(12);
ptr<size_t> countp = new ptr<size_t>(0);
gmp_lib.mpz_export(data, countp, -1, 4, 1, 0, op);

// Assert the result.
byte[] result = new byte[12];
Marshal.Copy(data.ToIntPtr(), result, 0, 12);
Assert.IsTrue(result[0] == 0x00);
Assert.IsTrue(result[1] == 0x00);
Assert.IsTrue(result[2] == 0x00);
Assert.IsTrue(result[3] == 0x01);
Assert.IsTrue(result[4] == 0x00);
Assert.IsTrue(result[5] == 0x00);
Assert.IsTrue(result[6] == 0x00);
Assert.IsTrue(result[7] == 0x00);
Assert.IsTrue(result[8] == 0x80);
Assert.IsTrue(result[9] == 0x00);
Assert.IsTrue(result[10] == 0x00);
Assert.IsTrue(result[11] == 0x00);

// Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(op);
gmp_lib.free(data);
gmp_lib.free(value);
' Create, initialize, and set the value of op to 0x800000000000000000000001.
Dim op As New mpz_t()
Dim value As New char_ptr("800000000000000000000001")
gmp_lib.mpz_init_set_str(op, value, 16)

' Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
Dim data As void_ptr = gmp_lib.allocate(12)
Dim countp As New ptr(Of size_t)(0)
gmp_lib.mpz_export(data, countp, -1, 4, 1, 0, op)

' Assert the result.
Dim result As Byte() = New Byte(11) { }
Marshal.Copy(data.ToIntPtr(), result, 0, 12)
Assert.IsTrue(result(0) = &H0)
Assert.IsTrue(result(1) = &H0)
Assert.IsTrue(result(2) = &H0)
Assert.IsTrue(result(3) = &H1)
Assert.IsTrue(result(4) = &H0)
Assert.IsTrue(result(5) = &H0)
Assert.IsTrue(result(6) = &H0)
Assert.IsTrue(result(7) = &H0)
Assert.IsTrue(result(8) = &H80)
Assert.IsTrue(result(9) = &H0)
Assert.IsTrue(result(10) = &H0)
Assert.IsTrue(result(11) = &H0)

' Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(op)
gmp_lib.free(data)
gmp_lib.free(value)

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

Reference

gmp_lib Class
mpz_export Overload
Math.Gmp.Native Namespace
mpz_import


gmp_lib.mpz_export Method (void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t)

gmp_libmpz_export Method (void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t)
Fill rop with word data from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void_ptr mpz_export(
    void_ptr rop,
    ref size_t countp,
    int order,
    size_t size,
    int endian,
    size_t nails,
    mpz_t op
)
Public Shared Function mpz_export (
    rop As void_ptr,
    ByRef countp As size_t,
    order As Integer,
    size As size_t,
    endian As Integer,
    nails As size_t,
    op As mpz_t
) As void_ptr
public:
static void_ptr mpz_export(
    void_ptr rop,
    size_t% countp,
    int order,
    size_t size,
    int endian,
    size_t nails,
    mpz_t^ op
)
static member mpz_export :
        rop : void_ptr *
        countp : size_t byref *
        order : int *
        size : size_t *
        endian : int *
        nails : size_t *
        op : mpz_t -> void_ptr

Parameters

rop
Type: Math.Gmp.Nativevoid_ptr
The result integer.
countp
Type: Math.Gmp.Nativesize_t
The number of words produced.
order
Type: SystemInt32
1 for most significant word first or -1 for least significant first.
size
Type: Math.Gmp.Nativesize_t
The number of bytes in each word.
endian
Type: SystemInt32
1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU.
nails
Type: Math.Gmp.Nativesize_t
The number of most significant bits to skip.
op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: void_ptr
Either rop or the allocated block.
Remarks

The parameters specify the format of the data produced. Each word will be size bytes and order can be 1 for most significant word first or -1 for least significant first. Within each word endian can be 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. The most significant nails bits of each word are unused and set to zero, this can be 0 to produce full words.

The number of words produced is written to countp, or countp can be NULL to discard the count. rop must have enough space for the data, or if rop is NULL then a result array of the necessary size is allocated using the current GMP allocation function (see GNU MP - Custom Allocation). In either case the return value is the destination used, either rop or the allocated block.

If op is non-zero then the most significant word produced will be non-zero. If op is zero then the count returned will be zero and nothing written to rop. If rop is NULL in this case, no block is allocated, just NULL is returned.

The sign of op is ignored, just the absolute value is exported. An application can use mpz_sgn to get the sign and handle it as desired. (see GNU MP - Integer Comparisons)

There are no data alignment restrictions on rop, any address is allowed.

When an application is allocating space itself the required size can be determined with a calculation like the following. Since mpz_sizeinbase always returns at least 1, count here will be at least one, which avoids any portability problems with malloc(0), though if z is zero no space at all is actually needed (or written).

C++
Copy
numb = 8 * size - nail;
count = (mpz_sizeinbase(z, 2) + numb - 1) / numb;
p = malloc(count * size);
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 0x800000000000000000000001.
mpz_t op = new mpz_t();
char_ptr value = new char_ptr("800000000000000000000001");
gmp_lib.mpz_init_set_str(op, value, 16);

// Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
void_ptr data = gmp_lib.allocate(12);
size_t countp = 0;
gmp_lib.mpz_export(data, ref countp, -1, 4, 1, 0, op);

// Assert the result.
byte[] result = new byte[12];
Marshal.Copy(data.ToIntPtr(), result, 0, 12);
Assert.IsTrue(result[0] == 0x00);
Assert.IsTrue(result[1] == 0x00);
Assert.IsTrue(result[2] == 0x00);
Assert.IsTrue(result[3] == 0x01);
Assert.IsTrue(result[4] == 0x00);
Assert.IsTrue(result[5] == 0x00);
Assert.IsTrue(result[6] == 0x00);
Assert.IsTrue(result[7] == 0x00);
Assert.IsTrue(result[8] == 0x80);
Assert.IsTrue(result[9] == 0x00);
Assert.IsTrue(result[10] == 0x00);
Assert.IsTrue(result[11] == 0x00);

// Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(op);
gmp_lib.free(data);
gmp_lib.free(value);
' Create, initialize, and set the value of op to 0x800000000000000000000001.
Dim op As New mpz_t()
Dim value As New char_ptr("800000000000000000000001")
gmp_lib.mpz_init_set_str(op, value, 16)

' Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
Dim data As void_ptr = gmp_lib.allocate(12)
Dim countp As size_t = 0
gmp_lib.mpz_export(data, countp, -1, 4, 1, 0, op)

' Assert the result.
Dim result As Byte() = New Byte(11) { }
Marshal.Copy(data.ToIntPtr(), result, 0, 12)
Assert.IsTrue(result(0) = &H0)
Assert.IsTrue(result(1) = &H0)
Assert.IsTrue(result(2) = &H0)
Assert.IsTrue(result(3) = &H1)
Assert.IsTrue(result(4) = &H0)
Assert.IsTrue(result(5) = &H0)
Assert.IsTrue(result(6) = &H0)
Assert.IsTrue(result(7) = &H0)
Assert.IsTrue(result(8) = &H80)
Assert.IsTrue(result(9) = &H0)
Assert.IsTrue(result(10) = &H0)
Assert.IsTrue(result(11) = &H0)

' Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(op)
gmp_lib.free(data)
gmp_lib.free(value)

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

Reference

gmp_lib Class
mpz_export Overload
Math.Gmp.Native Namespace
mpz_import


gmp_lib.mpz_fac_ui Method

gmp_libmpz_fac_ui Method
Set rop to the factorial n!.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fac_ui(
    mpz_t rop,
    uint n
)
Public Shared Sub mpz_fac_ui (
    rop As mpz_t,
    n As UInteger
)
public:
static void mpz_fac_ui(
    mpz_t^ rop,
    unsigned int n
)
static member mpz_fac_ui :
        rop : mpz_t *
        n : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: SystemUInt32
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = 3!.
gmp_lib.mpz_fac_ui(rop, 3U);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = 3!.
gmp_lib.mpz_fac_ui(rop, 3UI)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_2fac_ui
mpz_mfac_uiui


gmp_lib.mpz_fdiv_q Method

gmp_libmpz_fdiv_q Method
Set the quotient q to floor(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fdiv_q(
    mpz_t q,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_fdiv_q (
    q As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_fdiv_q(
    mpz_t^ q,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_fdiv_q :
        q : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = floor(n / d).
gmp_lib.mpz_fdiv_q(q, n, d);

// Assert that q is floor(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);

// Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = floor(n / d).
gmp_lib.mpz_fdiv_q(q, n, d)

' Assert that q is floor(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)

' Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_q_2exp Method

gmp_libmpz_fdiv_q_2exp Method
Set the quotient q to floor(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fdiv_q_2exp(
    mpz_t q,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_fdiv_q_2exp (
    q As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_fdiv_q_2exp(
    mpz_t^ q,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_fdiv_q_2exp :
        q : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = floor(n / 2^2).
gmp_lib.mpz_fdiv_q_2exp(q, n, 2U);

// Assert that q is floor(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = floor(n / 2^2).
gmp_lib.mpz_fdiv_q_2exp(q, n, 2UI)

' Assert that q is floor(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2500)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_q_ui Method

gmp_libmpz_fdiv_q_ui Method
Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static long mpz_fdiv_q_ui(
    mpz_t q,
    mpz_t n,
    uint d
)
Public Shared Function mpz_fdiv_q_ui (
    q As mpz_t,
    n As mpz_t,
    d As UInteger
) As Long
public:
static long long mpz_fdiv_q_ui(
    mpz_t^ q,
    mpz_t^ n,
    unsigned int d
)
static member mpz_fdiv_q_ui :
        q : mpz_t *
        n : mpz_t *
        d : uint32 -> int64

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: Int64
Return the remainder r = | n - q * d |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = floor(n / 3) and return r = n - 3 * q.
// Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3U) == 1U);
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = floor(n / 3) and return r = n - 3 * q.
' Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3UI) = 1UI)
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_qr Method

gmp_libmpz_fdiv_qr Method
Set the quotient q to floor(n / d), and set the remainder r to n - q * d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fdiv_qr(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_fdiv_qr (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_fdiv_qr(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_fdiv_qr :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = floor(n / 3) and r = n - d * q.
gmp_lib.mpz_fdiv_qr(q, r, n, d);

// Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

' Set q = floor(n / 3) and r = n - d * q.
gmp_lib.mpz_fdiv_qr(q, r, n, d)
///
' Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_qr_ui Method

gmp_libmpz_fdiv_qr_ui Method
Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_fdiv_qr_ui(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_fdiv_qr_ui (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_fdiv_qr_ui(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_fdiv_qr_ui :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = floor(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3U) == 1U);

// Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

' Set q = floor(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3UI) = 1UI)

' Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_r Method

gmp_libmpz_fdiv_r Method
Set the remainder r to n - q * d where q = floor(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fdiv_r(
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_fdiv_r (
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_fdiv_r(
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_fdiv_r :
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - d * floor(n / d).
gmp_lib.mpz_fdiv_r(r, n, d);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - d * floor(n / d).
gmp_lib.mpz_fdiv_r(r, n, d)
' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_r_2exp Method

gmp_libmpz_fdiv_r_2exp Method
Set the remainder r to n - q * 2^b where q = floor(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fdiv_r_2exp(
    mpz_t r,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_fdiv_r_2exp (
    r As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_fdiv_r_2exp(
    mpz_t^ r,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_fdiv_r_2exp :
        r : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 2^2 * floor(n / 2^2)
gmp_lib.mpz_fdiv_r_2exp(r, n, 2U);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - 2^2 * floor(n / 2^2)
gmp_lib.mpz_fdiv_r_2exp(r, n, 2UI)

' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_r_ui Method

gmp_libmpz_fdiv_r_ui Method
Set the remainder r to n - q * d where q = floor(n / d), and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_fdiv_r_ui(
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_fdiv_r_ui (
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_fdiv_r_ui(
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_fdiv_r_ui :
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 3 * floor(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3U) == 1U);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - 3 * floor(n / 3), and return |r|.
Set r = n - 3 * floor(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3UI) = 1UI)

' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_qr_ui
mpz_fdiv_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fdiv_ui Method

gmp_libmpz_fdiv_ui Method
Return the remainder | r | where r = n - q * d, and where q = floor(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static long mpz_fdiv_ui(
    mpz_t n,
    uint d
)
Public Shared Function mpz_fdiv_ui (
    n As mpz_t,
    d As UInteger
) As Long
public:
static long long mpz_fdiv_ui(
    mpz_t^ n,
    unsigned int d
)
static member mpz_fdiv_ui :
        n : mpz_t *
        d : uint32 -> int64

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: Int64
The remainder | r | where r = n - q * d, and where q = floor(n / d).
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Assert that returned value is |n - 3 * floor(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3U) == 1U);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Assert that returned value is |n - 3 * floor(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3UI) = 1UI)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_fdiv_q
mpz_fdiv_r
mpz_fdiv_qr
mpz_fdiv_q_ui
mpz_fdiv_r_ui
mpz_fdiv_qr_ui
mpz_fdiv_q_2exp
mpz_fdiv_r_2exp
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_fib_ui Method

gmp_libmpz_fib_ui Method
Sets fn to to F[n], the n’th Fibonacci number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fib_ui(
    mpz_t fn,
    uint n
)
Public Shared Sub mpz_fib_ui (
    fn As mpz_t,
    n As UInteger
)
public:
static void mpz_fib_ui(
    mpz_t^ fn,
    unsigned int n
)
static member mpz_fib_ui :
        fn : mpz_t *
        n : uint32 -> unit

Parameters

fn
Type: Math.Gmp.Nativempz_t
The F[n] result.
n
Type: SystemUInt32
The operand integer.
Remarks

The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both mpz_fib2_ui and mpz_lucnum2_ui. The formulas for going from Fibonacci to Lucas can be found in GNU MP - Lucas Numbers Algorithm, the reverse is straightforward too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of fn to 0.
mpz_t fn = new mpz_t();
gmp_lib.mpz_init(fn);

// Set fn to the n'th Fibonacci number.
gmp_lib.mpz_fib_ui(fn, 20U);

// Assert that fn is 6765.
Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765);

// Release unmanaged memory allocated for fn.
gmp_lib.mpz_clear(fn);
' Create, initialize, and set the value of fn to 0.
Dim fn As New mpz_t()
gmp_lib.mpz_init(fn)

' Set fn to the n'th Fibonacci number.
gmp_lib.mpz_fib_ui(fn, 20UI)

' Assert that fn is 6765.
Assert.IsTrue(gmp_lib.mpz_get_si(fn) = 6765)

' Release unmanaged memory allocated for fn.
gmp_lib.mpz_clear(fn)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fib2_ui


gmp_lib.mpz_fib2_ui Method

gmp_libmpz_fib2_ui Method
Sets fn to F[n], and fnsub1 to F[n - 1].

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_fib2_ui(
    mpz_t fn,
    mpz_t fnsub1,
    uint n
)
Public Shared Sub mpz_fib2_ui (
    fn As mpz_t,
    fnsub1 As mpz_t,
    n As UInteger
)
public:
static void mpz_fib2_ui(
    mpz_t^ fn,
    mpz_t^ fnsub1,
    unsigned int n
)
static member mpz_fib2_ui :
        fn : mpz_t *
        fnsub1 : mpz_t *
        n : uint32 -> unit

Parameters

fn
Type: Math.Gmp.Nativempz_t
The F[n] result.
fnsub1
Type: Math.Gmp.Nativempz_t
The F[n - 1] result.
n
Type: SystemUInt32
The operand integer.
Remarks

This function is designed for calculating isolated Fibonacci numbers. When a sequence of values is wanted it’s best to start with mpz_fib2_ui and iterate the defining F[n + 1] = F[n] + F[n - 1] or similar.

The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both mpz_fib2_ui and mpz_lucnum2_ui. The formulas for going from Fibonacci to Lucas can be found in GNU MP - Lucas Numbers Algorithm, the reverse is straightforward too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the values of fn and fnsub1 to 0.
mpz_t fn = new mpz_t();
mpz_t fnsub1 = new mpz_t();
gmp_lib.mpz_inits(fn, fnsub1, null);

// Set fnsub1 and fn to the 19'th and 20'th Fibonacci numbers respectively.
gmp_lib.mpz_fib2_ui(fn, fnsub1, 20U);

// Assert that fnsub1 and fn are respectively 4181 and 6765.
Assert.IsTrue(gmp_lib.mpz_get_si(fnsub1) == 4181);
Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765);

// Release unmanaged memory allocated for fn and fnsub1.
gmp_lib.mpz_clears(fn, fnsub1, null);
' Create, initialize, and set the values of fn and fnsub1 to 0.
Dim fn As New mpz_t()
Dim fnsub1 As New mpz_t()
gmp_lib.mpz_inits(fn, fnsub1, Nothing)

' Set fnsub1 and fn to the 19'th and 20'th Fibonacci numbers respectively.
gmp_lib.mpz_fib2_ui(fn, fnsub1, 20UI)

' Assert that fnsub1 and fn are respectively 4181 and 6765.
Assert.IsTrue(gmp_lib.mpz_get_si(fnsub1) = 4181)
Assert.IsTrue(gmp_lib.mpz_get_si(fn) = 6765)

' Release unmanaged memory allocated for fn and fnsub1.
gmp_lib.mpz_clears(fn, fnsub1, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fib_ui


gmp_lib.mpz_fits_sint_p Method

gmp_libmpz_fits_sint_p Method
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_sint_p(
    mpz_t op
)
Public Shared Function mpz_fits_sint_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_sint_p(
    mpz_t^ op
)
static member mpz_fits_sint_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpz_fits_sint_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in int.
Assert.IsTrue(gmp_lib.mpz_fits_sint_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_fits_slong_p Method

gmp_libmpz_fits_slong_p Method
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_slong_p(
    mpz_t op
)
Public Shared Function mpz_fits_slong_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_slong_p(
    mpz_t^ op
)
static member mpz_fits_slong_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in long.
Assert.IsTrue(gmp_lib.mpz_fits_slong_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in long.
Assert.IsTrue(gmp_lib.mpz_fits_slong_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_fits_sshort_p Method

gmp_libmpz_fits_sshort_p Method
Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_sshort_p(
    mpz_t op
)
Public Shared Function mpz_fits_sshort_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_sshort_p(
    mpz_t^ op
)
static member mpz_fits_sshort_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in short.
Assert.IsTrue(gmp_lib.mpz_fits_sshort_p(op) ==  0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in short.
Assert.IsTrue(gmp_lib.mpz_fits_sshort_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_fits_uint_p Method

gmp_libmpz_fits_uint_p Method
Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_uint_p(
    mpz_t op
)
Public Shared Function mpz_fits_uint_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_uint_p(
    mpz_t^ op
)
static member mpz_fits_uint_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in uint.
Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in uint.
Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_fits_ulong_p Method

gmp_libmpz_fits_ulong_p Method
Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_ulong_p(
    mpz_t op
)
Public Shared Function mpz_fits_ulong_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_ulong_p(
    mpz_t^ op
)
static member mpz_fits_ulong_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op fits in ulong.
Assert.IsTrue(gmp_lib.mpz_fits_ulong_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op fits in ulong.
Assert.IsTrue(gmp_lib.mpz_fits_ulong_p(op) > 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_fits_ushort_p Method

gmp_libmpz_fits_ushort_p Method
Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_fits_ushort_p(
    mpz_t op
)
Public Shared Function mpz_fits_ushort_p (
    op As mpz_t
) As Integer
public:
static int mpz_fits_ushort_p(
    mpz_t^ op
)
static member mpz_fits_ushort_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op 4294967295.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, uint.MaxValue);

// Assert that op does not fit in ushort.
Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op 4294967295.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue)

' Assert that op does not fit in ushort.
Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_gcd Method

gmp_libmpz_gcd Method
Set rop to the greatest common divisor of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_gcd(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_gcd (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_gcd(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_gcd :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result operand integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The result is always positive even if one or both input operands are negative. Except if both inputs are zero; then this function defines gcd(0,0) = 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the greatest common divisor of op1 and op2.
gmp_lib.mpz_gcd(rop, op1, op2);

// Assert that rop is 7.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 7);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the greatest common divisor of op1 and op2.
gmp_lib.mpz_gcd(rop, op1, op2)

' Assert that rop is 7.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 7)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_gcd_ui
mpz_gcdext


gmp_lib.mpz_gcd_ui Method

gmp_libmpz_gcd_ui Method
Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_gcd_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Function mpz_gcd_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
) As UInteger
public:
static unsigned int mpz_gcd_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_gcd_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> uint32

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result operand integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.

Return Value

Type: UInt32
If the result is small enough to fit in an unsigned int, it is returned. If the result does not fit, 0 is returned, and the result is equal to the argument op1.
Remarks

Note that the result will always fit if op2 is non-zero.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Return the greatest common divisor of op1 and 70.
Assert.IsTrue(gmp_lib.mpz_gcd_ui(null, op1, 70U) == 7);

// Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Return the greatest common divisor of op1 and 70.
Assert.IsTrue(gmp_lib.mpz_gcd_ui(Nothing, op1, 70UI) = 7)
' Release unmanaged memory allocated for op1.
gmp_lib.mpz_clear(op1)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_gcd
mpz_gcdext


gmp_lib.mpz_gcdext Method

gmp_libmpz_gcdext Method
Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_gcdext(
    mpz_t g,
    mpz_t s,
    mpz_t t,
    mpz_t a,
    mpz_t b
)
Public Shared Sub mpz_gcdext (
    g As mpz_t,
    s As mpz_t,
    t As mpz_t,
    a As mpz_t,
    b As mpz_t
)
public:
static void mpz_gcdext(
    mpz_t^ g,
    mpz_t^ s,
    mpz_t^ t,
    mpz_t^ a,
    mpz_t^ b
)
static member mpz_gcdext :
        g : mpz_t *
        s : mpz_t *
        t : mpz_t *
        a : mpz_t *
        b : mpz_t -> unit

Parameters

g
Type: Math.Gmp.Nativempz_t
The greateast common divisor.
s
Type: Math.Gmp.Nativempz_t
The first result coefficient.
t
Type: Math.Gmp.Nativempz_t
The second result coefficient.
a
Type: Math.Gmp.Nativempz_t
The first operand integer.
b
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The value in g is always positive, even if one or both of a and b are negative (or zero if both inputs are zero). The values in s and t are chosen such that normally, | s | < | b | / (2 g) and | t | < | a | / (2 g), and these relations define s and t uniquely. There are a few exceptional cases:

If | a | = | b |, then s = 0, t = sgn(b).

Otherwise, s = sgn(a) if b = 0
or | b | = 2 g, and t = sgn(b)
if a = 0 or | a | = 2 g.

In all cases, s = 0 if and only if g = | b |, i.e., if b divides a or a = b = 0.

If t is null then that value is not computed.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t b = new mpz_t();
gmp_lib.mpz_init_set_ui(b, 70U);

// Create, initialize, and set the values of g, s, and t to 0.
mpz_t g = new mpz_t();
mpz_t s = new mpz_t();
mpz_t t = new mpz_t();
gmp_lib.mpz_inits(g, s, t, null);

// Set g to the the greatest common divisor of a and b, and set s and t such that a * s + b * t = g.
gmp_lib.mpz_gcdext(g, s, t, a, b);

// Assert that g is 7, and that s and t are respectively -1 and 1.
Assert.IsTrue(gmp_lib.mpz_get_si(g) == 7);
Assert.IsTrue(gmp_lib.mpz_get_si(s) == -1);
Assert.IsTrue(gmp_lib.mpz_get_si(t) == 1);

// Release unmanaged memory allocated for g, s, t, a, and b.
gmp_lib.mpz_clears(g, s, t, a, b, null);
' Create, initialize, and set the value of op1 to 63.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim b As New mpz_t()
gmp_lib.mpz_init_set_ui(b, 70UI)

' Create, initialize, and set the values of g, s, and t to 0.
Dim g As New mpz_t()
Dim s As New mpz_t()
Dim t As New mpz_t()
gmp_lib.mpz_inits(g, s, t, Nothing)

' Set g to the the greatest common divisor of a and b, and set s and t such that a * s + b * t = g.
gmp_lib.mpz_gcdext(g, s, t, a, b)

' Assert that g is 7, and that s and t are respectively -1 and 1.
Assert.IsTrue(gmp_lib.mpz_get_si(g) = 7)
Assert.IsTrue(gmp_lib.mpz_get_si(s) = -1)
Assert.IsTrue(gmp_lib.mpz_get_si(t) = 1)

' Release unmanaged memory allocated for g, s, t, a, and b.
gmp_lib.mpz_clears(g, s, t, a, b, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_gcd
mpz_gcd_ui


gmp_lib.mpz_get_d Method

gmp_libmpz_get_d Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static double mpz_get_d(
    mpz_t op
)
Public Shared Function mpz_get_d (
    op As mpz_t
) As Double
public:
static double mpz_get_d(
    mpz_t^ op
)
static member mpz_get_d :
        op : mpz_t -> float

Parameters

op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: Double
op as a double, truncating it if necessary (i.e. rounding towards zero).
Remarks

If the exponent from the conversion is too big, the result is system dependent. An infinity is returned where available. A hardware overflow trap may or may not occur.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_d(x, 10.7D);

// Assert that the value of x is 10.0.
Assert.IsTrue(gmp_lib.mpz_get_d(x) == 10.0);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_d(x, 10.7)

' Assert that the value of x is 10.0.
Assert.IsTrue(gmp_lib.mpz_get_d(x) = 10.0)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_get_d_2exp
mpz_get_si
mpz_get_str
mpz_get_ui


gmp_lib.mpz_get_d_2exp Method

gmp_libmpz_get_d_2exp Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static double mpz_get_d_2exp(
    ref int exp,
    mpz_t op
)
Public Shared Function mpz_get_d_2exp (
    ByRef exp As Integer,
    op As mpz_t
) As Double
public:
static double mpz_get_d_2exp(
    int% exp,
    mpz_t^ op
)
static member mpz_get_d_2exp :
        exp : int byref *
        op : mpz_t -> float

Parameters

exp
Type: SystemInt32
The returned exponent.
op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: Double
op as a double, truncating if necessary (i.e. rounding towards zero).
Remarks

The return value is in the range 0.5 ≤ | d | < 1 and the exponent is stored to exp. d x 2^exp is the (truncated) op value. If op is zero, the return value is 0.0 and 0 is stored to exp.

This is similar to the standard C frexp function.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 2^20.
mpz_t x = new mpz_t();
char_ptr value = new char_ptr("100000000000000000000");
gmp_lib.mpz_init_set_str(x, value, 2);

// Assert that x is equal to 0.5^21.
int exp = 0;
Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D);
Assert.IsTrue(exp == 21);

// Release unmanaged memory allocated for x and the string value.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
' Create, initialize, and set the value of x to 2^20.
Dim x As New mpz_t()
Dim value As New char_ptr("100000000000000000000")
gmp_lib.mpz_init_set_str(x, value, 2)

' Assert that x is equal to 0.5^21.
Dim exp As Integer = 0
Assert.IsTrue(gmp_lib.mpz_get_d_2exp(exp, x) = 0.5)
Assert.IsTrue(exp = 21)

' Release unmanaged memory allocated for x and the string value.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_get_d
mpz_get_si
mpz_get_str
mpz_get_ui


gmp_lib.mpz_get_si Method

gmp_libmpz_get_si Method
Return the value of op as an signed long.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_get_si(
    mpz_t op
)
Public Shared Function mpz_get_si (
    op As mpz_t
) As Integer
public:
static int mpz_get_si(
    mpz_t^ op
)
static member mpz_get_si :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: Int32
The value of op as an signed long.
Remarks

If op fits into a signed long int return the value of op. Otherwise return the least significant part of op, with the same sign as op.

If op is too big to fit in a signed long int, the returned result is probably not very useful. To find out if the value will fit, use the function mpz_fits_slong_p.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10);

// Retrieve the value of x, and assert that it is -10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to -10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10)

' Retrieve the value of x, and assert that it is -10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -10)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_get_d
mpz_get_d_2exp
mpz_get_str
mpz_get_ui


gmp_lib.mpz_get_str Method

gmp_libmpz_get_str Method
Convert op to a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static char_ptr mpz_get_str(
    char_ptr str,
    int base,
    mpz_t op
)
Public Shared Function mpz_get_str (
    str As char_ptr,
    base As Integer,
    op As mpz_t
) As char_ptr
public:
static char_ptr mpz_get_str(
    char_ptr str,
    int base,
    mpz_t^ op
)
static member mpz_get_str :
        str : char_ptr *
        base : int *
        op : mpz_t -> char_ptr

Parameters

str
Type: Math.Gmp.Nativechar_ptr
The converted integer.
base
Type: SystemInt32
The base.
op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: char_ptr
A pointer to the result string is returned, being either the allocated block, or the given str.
Remarks

The base argument may vary from 2 to 62 or from −2 to −36.

For base in the range 2..36, digits and lower-case letters are used; for −2..−36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.

If str is char_ptr.Zero, the result string is allocated using the current allocation function. The block will be strlen(str)+1 bytes, that being exactly enough for the string and null-terminator.

If str is not char_ptr.Zero, it should point to a block of storage large enough for the result, that being mpz_sizeinbase(op, base) + 2. The two extra bytes are for a possible minus sign, and the null-terminator.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -210.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -210);

// Retrieve the string value of x, and assert that it is "-210".
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == "-210");

// Release unmanaged memory allocated for x and the string value.
gmp_lib.mpz_clear(x);
gmp_lib.free(s);
' Create, initialize, and set the value of x to -210.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -210)

' Retrieve the string value of x, and assert that it is "-210".
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x)
Assert.IsTrue(s.ToString() = "-210")

' Release unmanaged memory allocated for x and the string value.
gmp_lib.mpz_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_get_d
mpz_get_d_2exp
mpz_get_si
mpz_get_ui


gmp_lib.mpz_get_ui Method

gmp_libmpz_get_ui Method
Return the value of op as an unsigned long.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_get_ui(
    mpz_t op
)
Public Shared Function mpz_get_ui (
    op As mpz_t
) As UInteger
public:
static unsigned int mpz_get_ui(
    mpz_t^ op
)
static member mpz_get_ui :
        op : mpz_t -> uint32

Parameters

op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: UInt32
The value of op as an unsigned long.
Remarks

If op is too big to fit an unsigned long then just the least significant bits that do fit are returned. The sign of op is ignored, only the absolute value is used.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10U);

// Retrieve the value of x, and assert that it is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10UI)

' Retrieve the value of x, and assert that it is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_get_d
mpz_get_d_2exp
mpz_get_si
mpz_get_str


gmp_lib.mpz_getlimbn Method

gmp_libmpz_getlimbn Method
Return limb number n from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_limb_t mpz_getlimbn(
    mpz_t op,
    mp_size_t n
)
Public Shared Function mpz_getlimbn (
    op As mpz_t,
    n As mp_size_t
) As mp_limb_t
public:
static mp_limb_t mpz_getlimbn(
    mpz_t^ op,
    mp_size_t n
)
static member mpz_getlimbn :
        op : mpz_t *
        n : mp_size_t -> mp_limb_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The zero-based limb index.

Return Value

Type: mp_limb_t
The limb number n from op.
Remarks

The sign of op is ignored, just the absolute value is used. The least significant limb is number 0.

mpz_size can be used to find how many limbs make up op. mpz_getlimbn returns zero if n is outside the range 0 to mpz_size(op) - 1.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t op = new mpz_t();
char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD");
gmp_lib.mpz_init_set_str(op, value, 16);

// Assert the value of the limbs of op.
if (gmp_lib.mp_bytes_per_limb == 4)
{
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0x7AB824FD);
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0xABCD1234);
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) == 0x00001000);
}
else // gmp_lib.mp_bytes_per_limb == 8
{
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0xABCD12347AB824FD);
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0x0000000000001000);
}

// Release unmanaged memory allocated for op and value.
gmp_lib.mpz_clear(op);
gmp_lib.free(value);
' Create and initialize new integer x.
Dim op As New mpz_t()
Dim value As New char_ptr("1000 ABCD 1234 7AB8 24FD")
gmp_lib.mpz_init_set_str(op, value, 16)

' Assert the value of the limbs of op.
If gmp_lib.mp_bytes_per_limb = 4 Then
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) = &H7ab824fd)
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) = &Habcd1234UI)
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) = &H1000)
Else ' gmp_lib.mp_bytes_per_limb == 8
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) = &Habcd12347ab824fdUL)
    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) = &H1000)
End If

' Release unmanaged memory allocated for op and value.
gmp_lib.mpz_clear(op)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_size
mpz_limbs_read
mpz_limbs_write
mpz_limbs_modify
mpz_limbs_finish
mpz_roinit_n


gmp_lib.mpz_hamdist Method

gmp_libmpz_hamdist Method
Return the hamming distance between the two operands.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpz_hamdist(
    mpz_t op1,
    mpz_t op2
)
Public Shared Function mpz_hamdist (
    op1 As mpz_t,
    op2 As mpz_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_hamdist(
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_hamdist :
        op1 : mpz_t *
        op2 : mpz_t -> mp_bitcnt_t

Parameters

op1
Type: Math.Gmp.Nativempz_t
The first operanf integer.
op2
Type: Math.Gmp.Nativempz_t
The second operanf integer.

Return Value

Type: mp_bitcnt_t
The hamming distance between the two operands.
Remarks

If op1 and op2 are both ≥ 0 or both < 0, return the hamming distance between the two operands, which is the number of bit positions where op1 and op2 have different bit values. If one operand is ≥ 0 and the other < 0 then the number of bits different is infinite, and the return value is the largest possible mp_bitcnt_t.

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Assert that the Hamming distance between op1 and op2 is 5.
Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) == 5U);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Assert that the Hamming distance between op1 and op2 is 5.
Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) = 5UI)

' Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpz_clears(op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_import Method

gmp_libmpz_import Method
Set rop from an array of word data at op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_import(
    mpz_t rop,
    size_t count,
    int order,
    size_t size,
    int endian,
    size_t nails,
    void_ptr op
)
Public Shared Sub mpz_import (
    rop As mpz_t,
    count As size_t,
    order As Integer,
    size As size_t,
    endian As Integer,
    nails As size_t,
    op As void_ptr
)
public:
static void mpz_import(
    mpz_t^ rop,
    size_t count,
    int order,
    size_t size,
    int endian,
    size_t nails,
    void_ptr op
)
static member mpz_import :
        rop : mpz_t *
        count : size_t *
        order : int *
        size : size_t *
        endian : int *
        nails : size_t *
        op : void_ptr -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
count
Type: Math.Gmp.Nativesize_t
The number of words to read.
order
Type: SystemInt32
1 for most significant word first or -1 for least significant first.
size
Type: Math.Gmp.Nativesize_t
The number of bytes in each word.
endian
Type: SystemInt32
1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU.
nails
Type: Math.Gmp.Nativesize_t
The number of most significant bits to skip.
op
Type: Math.Gmp.Nativevoid_ptr
The operand integer.
Remarks

The parameters specify the format of the data. count many words are read, each size bytes. order can be 1 for most significant word first or -1 for least significant first. Within each word endian can be 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. The most significant nails bits of each word are skipped, this can be 0 to use the full words.

There is no sign taken from the data, rop will simply be a positive integer. An application can handle any sign itself, and apply it for instance with mpz_neg.

There are no data alignment restrictions on op, any address is allowed.

Here’s an example converting an array of unsigned long data, most significant element first, and host byte order within each value.

C++
Copy
unsigned long a[20];
/* Initialize z and a */
mpz_import(z, 20, 1, sizeof(a[0]), 0, 0, a);

This example assumes the full sizeof bytes are used for data in the given type, which is usually true, and certainly true for unsigned long everywhere we know of. However on Cray vector systems it may be noted that short and int are always stored in 8 bytes (and with sizeof indicating that) but use only 32 or 46 bits. The nails feature can account for this, by passing for instance 8 * sizeof(int) - INT_BIT.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Copy 0x800000000000000000000001, 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
void_ptr data = gmp_lib.allocate(12);
Marshal.Copy(new byte[] { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, 0, data.ToIntPtr(), 12);

// Import value into rop.
gmp_lib.mpz_import(rop, 3, -1, 4, 1, 0, data);

// Assert the value of rop.
char_ptr value = gmp_lib.mpz_get_str(char_ptr.Zero, 16, rop);
Assert.IsTrue(value.ToString() == "800000000000000000000001");

// Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(rop);
gmp_lib.free(data);
gmp_lib.free(value);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Copy 0x800000000000000000000001, 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb.
Dim data As void_ptr = gmp_lib.allocate(12)
Marshal.Copy(New Byte() { &H0, &H0, &H0, &H1, &H0, &H0, &H0, &H0, &H80, &H0, &H0, &H0}, 0, data.ToIntPtr(), 12)

' Import value into rop.
gmp_lib.mpz_import(rop, 3, -1, 4, 1, 0, data)

' Assert the value of rop.
Dim value As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, rop)
Assert.IsTrue(value.ToString() = "800000000000000000000001")

' Release unmanaged memory allocated for rop, data, and value.
gmp_lib.mpz_clear(rop)
gmp_lib.free(data)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
O:Math.Gmp.Native.gmp_lib.mpz_export


gmp_lib.mpz_init Method

gmp_libmpz_init Method
Initialize x, and set its value to 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init(
    mpz_t x
)
Public Shared Sub mpz_init (
    x As mpz_t
)
public:
static void mpz_init(
    mpz_t^ x
)
static member mpz_init :
        x : mpz_t -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Assert that the value of x is 0.
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == "0");

// Release unmanaged memory allocated for x and its string value.
gmp_lib.mpz_clear(x);
gmp_lib.free(s);
' Create and initialize a new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Assert that the value of x is 0.
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x)
Assert.IsTrue(s.ToString() = "0")

' Release unmanaged memory allocated for x and its string value.
gmp_lib.mpz_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clear
mpz_clears
mpz_inits
mpz_init2
mpz_realloc2


gmp_lib.mpz_init_set Method

gmp_libmpz_init_set Method
Initialize rop with limb space and set the initial numeric value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init_set(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_init_set (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_init_set(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_init_set :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: Math.Gmp.Nativempz_t
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new integer y to -210.
mpz_t y = new mpz_t();
gmp_lib.mpz_init(y);
gmp_lib.mpz_set_si(y, -210);

// Create, initialize, and set a new integer x to the value of y.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set(x, y);

// Assert that x is equal to the value of y.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, null);
' Create, initialize, and set a new integer y to -210.
Dim y As New mpz_t()

gmp_lib.mpz_init(y)
gmp_lib.mpz_set_si(y, -210)

' Create, initialize, and set a new integer x to the value of y.
Dim x As New mpz_t()
gmp_lib.mpz_init_set(x, y)

' Assert that x is equal to the value of y.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_init_set_ui
mpz_init_set_si
mpz_init_set_d
mpz_init_set_str


gmp_lib.mpz_init_set_d Method

gmp_libmpz_init_set_d Method
Initialize rop with limb space and set the initial numeric value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init_set_d(
    mpz_t rop,
    double op
)
Public Shared Sub mpz_init_set_d (
    rop As mpz_t,
    op As Double
)
public:
static void mpz_init_set_d(
    mpz_t^ rop,
    double op
)
static member mpz_init_set_d :
        rop : mpz_t *
        op : float -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemDouble
The source integer.
Remarks

mpz_init_set_d truncate op to make it an integer.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to the truncation of 10.7.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_d(x, 10.7D);

// Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to the truncation of 10.7.
Dim x As New mpz_t()

gmp_lib.mpz_init_set_d(x, 10.7)

' Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_init_set
mpz_init_set_ui
mpz_init_set_si
mpz_init_set_str


gmp_lib.mpz_init_set_si Method

gmp_libmpz_init_set_si Method
Initialize rop with limb space and set the initial numeric value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init_set_si(
    mpz_t rop,
    int op
)
Public Shared Sub mpz_init_set_si (
    rop As mpz_t,
    op As Integer
)
public:
static void mpz_init_set_si(
    mpz_t^ rop,
    int op
)
static member mpz_init_set_si :
        rop : mpz_t *
        op : int -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemInt32
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, 10);

// Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10.
Dim x As New mpz_t()

gmp_lib.mpz_init_set_si(x, 10)

' Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_init_set
mpz_init_set_ui
mpz_init_set_d
mpz_init_set_str


gmp_lib.mpz_init_set_str Method

gmp_libmpz_init_set_str Method
Initialize rop and set its value like mpz_set_str.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_init_set_str(
    mpz_t rop,
    char_ptr str,
    int base
)
Public Shared Function mpz_init_set_str (
    rop As mpz_t,
    str As char_ptr,
    base As Integer
) As Integer
public:
static int mpz_init_set_str(
    mpz_t^ rop,
    char_ptr str,
    int base
)
static member mpz_init_set_str :
        rop : mpz_t *
        str : char_ptr *
        base : int -> int

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
str
Type: Math.Gmp.Nativechar_ptr
The source integer.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
If the string is a correct base base number, the function returns 0; if an error occurs it returns −1. rop is initialized even if an error occurs.
Remarks

See mpz_set_str for details.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x.
mpz_t x = new mpz_t();
char_ptr value = new char_ptr("  1 234 567 890 876 543 211 234 567 890 987 654 321  ");
gmp_lib.mpz_init_set_str(x, value, 10);

// Assert the value of x.
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", ""));

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
' Create, initialize, and set the value of x.
Dim x As New mpz_t()
Dim value As New char_ptr("  1 234 567 890 876 543 211 234 567 890 987 654 321  ")
gmp_lib.mpz_init_set_str(x, value, 10)

' Assert the value of x.
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x)

Assert.IsTrue(s.ToString() = value.ToString().Replace(" ", ""))
' Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_init_set
mpz_init_set_ui
mpz_init_set_si
mpz_init_set_d


gmp_lib.mpz_init_set_ui Method

gmp_libmpz_init_set_ui Method
Initialize rop with limb space and set the initial numeric value from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init_set_ui(
    mpz_t rop,
    uint op
)
Public Shared Sub mpz_init_set_ui (
    rop As mpz_t,
    op As UInteger
)
public:
static void mpz_init_set_ui(
    mpz_t^ rop,
    unsigned int op
)
static member mpz_init_set_ui :
        rop : mpz_t *
        op : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemUInt32
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10U);

// Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create, initialize, and set the value of x to 10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10UI)

' Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_init_set
mpz_init_set_si
mpz_init_set_d
mpz_init_set_str


gmp_lib.mpz_init2 Method

gmp_libmpz_init2 Method
Initialize x, with space for n-bit numbers, and set its value to 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_init2(
    mpz_t x,
    mp_bitcnt_t n
)
Public Shared Sub mpz_init2 (
    x As mpz_t,
    n As mp_bitcnt_t
)
public:
static void mpz_init2(
    mpz_t^ x,
    mp_bitcnt_t n
)
static member mpz_init2 :
        x : mpz_t *
        n : mp_bitcnt_t -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.
n
Type: Math.Gmp.Nativemp_bitcnt_t
The number of bits.
Remarks

Calling this function instead of mpz_init or mpz_inits is never necessary; reallocation is handled automatically by GMP when needed.

While n defines the initial space, x will grow automatically in the normal way, if necessary, for subsequent values stored. mpz_init2 makes it possible to avoid such reallocations if a maximum size is known in advance.

In preparation for an operation, GMP often allocates one limb more than ultimately needed. To make sure GMP will not perform reallocation for x, you need to add the number of bits in mp_limb_t to n.

Examples
C#
VB
C++
F#
Copy
// Create a new integer x, and initialize its size to 300 bits.
mpz_t x = new mpz_t();
gmp_lib.mpz_init2(x, 300);

// Assert that the value of x is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create a new integer x, and initialize its size to 300 bits.
Dim x As New mpz_t()
gmp_lib.mpz_init2(x, 300)

' Assert that the value of x is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clear
mpz_clears
mpz_init
mpz_inits
mpz_realloc2


gmp_lib.mpz_inits Method

gmp_libmpz_inits Method
Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_inits(
    params mpz_t[] x
)
Public Shared Sub mpz_inits (
    ParamArray x As mpz_t()
)
public:
static void mpz_inits(
    ... array<mpz_t^>^ x
)
static member mpz_inits :
        x : mpz_t[] -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
A NULL-terminated list of mpz_t variables.
Examples
C#
VB
C++
F#
Copy
// Create new integers x1, x2 and x3.
mpz_t x1 = new mpz_t();
mpz_t x2 = new mpz_t();
mpz_t x3 = new mpz_t();

// Initialize the integers.
gmp_lib.mpz_inits(x1, x2, x3, null);

// Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0);
Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0);
Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0);

// Release unmanaged memory allocated for the integers.
gmp_lib.mpz_clears(x1, x2, x3, null);
' Create new integers x1, x2 and x3.
Dim x1 As New mpz_t()
Dim x2 As New mpz_t()
Dim x3 As New mpz_t()

' Initialize the integers.
gmp_lib.mpz_inits(x1, x2, x3, Nothing)

' Assert that their value is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(x1) = 0)
Assert.IsTrue(gmp_lib.mpz_get_si(x2) = 0)
Assert.IsTrue(gmp_lib.mpz_get_si(x3) = 0)

' Release unmanaged memory allocated for the integers.
gmp_lib.mpz_clears(x1, x2, x3, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clear
mpz_clears
mpz_init
mpz_init2
mpz_realloc2


gmp_lib.mpz_inp_raw Method

gmp_libmpz_inp_raw Method
Input from stdio stream stream in the format written by mpz_out_raw, and put the result in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpz_inp_raw(
    mpz_t rop,
    ptr<FILE> stream
)
Public Shared Function mpz_inp_raw (
    rop As mpz_t,
    stream As ptr(Of FILE)
) As size_t
public:
static size_t mpz_inp_raw(
    mpz_t^ rop,
    ptr<FILE>^ stream
)
static member mpz_inp_raw :
        rop : mpz_t *
        stream : ptr<FILE> -> size_t

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result operand.
stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.

Return Value

Type: size_t
Return the number of bytes read, or if an error occurred, return 0.
Remarks

This routine can read the output from mpz_out_raw also from GMP 1, in spite of changes necessary for compatibility between 32-bit and 64-bit machines.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123456.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 123456U);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7);
fclose(stream.Value.Value);

// Read op from the temporary file, and assert that the number of bytes read is 6.
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7);
fclose(stream.Value.Value);

// Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 123456.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 123456UI)

' Write op to a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "w")
Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) = 7)
fclose(stream.Value.Value)

' Read op from the temporary file, and assert that the number of bytes read is 6.
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) = 7)
fclose(stream.Value.Value)

' Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpz_get_ui(op) = 123456UI)

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_out_str
mpz_inp_str
mpz_out_raw


gmp_lib.mpz_inp_str Method

gmp_libmpz_inp_str Method
Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpz_inp_str(
    mpz_t rop,
    ptr<FILE> stream,
    int base
)
Public Shared Function mpz_inp_str (
    rop As mpz_t,
    stream As ptr(Of FILE),
    base As Integer
) As size_t
public:
static size_t mpz_inp_str(
    mpz_t^ rop,
    ptr<FILE>^ stream,
    int base
)
static member mpz_inp_str :
        rop : mpz_t *
        stream : ptr<FILE> *
        base : int -> size_t

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base operand.

Return Value

Type: size_t
Return the number of bytes read, or if an error occurred, return 0.
Remarks

The base may vary from 2 to 62, or if base is 0, then the leading characters are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or decimal otherwise.

For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter represent 36..61.

Examples
C#
VB
C++
F#
Copy
// Create and initialize op.
mpz_t op = new mpz_t();
gmp_lib.mpz_init(op);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(pathname, "123456");

// Read op from the temporary file, and assert that the number of bytes read is 6.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) == 6);
fclose(stream.Value.Value);

// Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create and initialize op.
Dim op As New mpz_t()
gmp_lib.mpz_init(op)

' Write op to a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()
System.IO.File.WriteAllText(pathname, "123456")

' Read op from the temporary file, and assert that the number of bytes read is 6.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "r")
Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) = 6)
fclose(stream.Value.Value)

' Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpz_get_ui(op) = 123456UI)

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_out_str
mpz_out_raw
mpz_inp_raw


gmp_lib.mpz_invert Method

gmp_libmpz_invert Method
Compute the inverse of op1 modulo op2 and put the result in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_invert(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Function mpz_invert (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
) As Integer
public:
static int mpz_invert(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_invert :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> int

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
If the inverse exists, the return value is non-zero. If an inverse doesn’t exist the return value is zero.
Remarks

If the inverse exists, the return value is non-zero and rop will satisfy 0 ≤ rop < | op2 | (with rop = 0 possible only when | op2 | = 1, i.e., in the somewhat degenerate zero ring). If an inverse doesn’t exist the return value is zero and rop is undefined. The behaviour of this function is undefined when op2 is zero.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 3.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 3U);

// Create, initialize, and set the value of op2 to 11.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 11U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1.
gmp_lib.mpz_invert(rop, op1, op2);

// Assert that rop is 4,
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 4);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 3.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 3UI)

' Create, initialize, and set the value of op2 to 11.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 11UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1.
gmp_lib.mpz_invert(rop, op1, op2)

' Assert that rop is 4,
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 4)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpz_ior Method

gmp_libmpz_ior Method
Set rop to op1 bitwise inclusive-or op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_ior(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_ior (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_ior(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_ior :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the bitwise inclusive or of op1 and op2.
gmp_lib.mpz_ior(rop, op1, op2);

// Assert that rop is 127.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 127);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the bitwise inclusive or of op1 and op2.
gmp_lib.mpz_ior(rop, op1, op2)

' Assert that rop is 127.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 127)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_jacobi Method

gmp_libmpz_jacobi Method
Calculate the Jacobi symbol (a/b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_jacobi(
    mpz_t a,
    mpz_t b
)
Public Shared Function mpz_jacobi (
    a As mpz_t,
    b As mpz_t
) As Integer
public:
static int mpz_jacobi(
    mpz_t^ a,
    mpz_t^ b
)
static member mpz_jacobi :
        a : mpz_t *
        b : mpz_t -> int

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
b
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b).
Remarks

This is defined only for b odd.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of a to 11.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 11U);

// Create, initialize, and set the value of b to 9.
mpz_t b = new mpz_t();
gmp_lib.mpz_init_set_ui(b, 9U);

// Assert that the Jacobi symbol of (a/b) is 1.
Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) == 1);

// Release unmanaged memory allocated for a and b.
gmp_lib.mpz_clears(a, b, null);
' Create, initialize, and set the value of a to 11.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 11UI)

' Create, initialize, and set the value of b to 9.
Dim b As New mpz_t()
gmp_lib.mpz_init_set_ui(b, 9UI)

' Assert that the Jacobi symbol of (a/b) is 1.
Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) = 1)

' Release unmanaged memory allocated for a and b.
gmp_lib.mpz_clears(a, b, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_legendre


gmp_lib.mpz_kronecker Method

gmp_libmpz_kronecker Method
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_kronecker(
    mpz_t a,
    mpz_t b
)
Public Shared Function mpz_kronecker (
    a As mpz_t,
    b As mpz_t
) As Integer
public:
static int mpz_kronecker(
    mpz_t^ a,
    mpz_t^ b
)
static member mpz_kronecker :
        a : mpz_t *
        b : mpz_t -> int

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
b
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Remarks

When b is odd the Jacobi symbol and Kronecker symbol are identical, so mpz_kronecker_ui, etc. can be used for mixed precision Jacobi symbols too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of a to 15.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 15U);

// Create, initialize, and set the value of b to 4.
mpz_t b = new mpz_t();
gmp_lib.mpz_init_set_ui(b, 4U);

// Assert that the Kronecker symbol of (a/b) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) == 1);

// Release unmanaged memory allocated for a and b.
gmp_lib.mpz_clears(a, b, null);
' Create, initialize, and set the value of a to 15.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 15UI)

' Create, initialize, and set the value of b to 4.
Dim b As New mpz_t()
gmp_lib.mpz_init_set_ui(b, 4UI)

' Assert that the Kronecker symbol of (a/b) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) = 1)

' Release unmanaged memory allocated for a and b.
gmp_lib.mpz_clears(a, b, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_kronecker_si
mpz_kronecker_ui
mpz_legendre
mpz_si_kronecker
mpz_ui_kronecker


gmp_lib.mpz_kronecker_si Method

gmp_libmpz_kronecker_si Method
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_kronecker_si(
    mpz_t a,
    int b
)
Public Shared Function mpz_kronecker_si (
    a As mpz_t,
    b As Integer
) As Integer
public:
static int mpz_kronecker_si(
    mpz_t^ a,
    int b
)
static member mpz_kronecker_si :
        a : mpz_t *
        b : int -> int

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
b
Type: SystemInt32
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Remarks

When b is odd the Jacobi symbol and Kronecker symbol are identical, so mpz_kronecker_ui, etc. can be used for mixed precision Jacobi symbols too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of a to 15.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 15U);

// Assert that the Kronecker symbol of (a/4) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) == 1);

// Release unmanaged memory allocated for a.
gmp_lib.mpz_clear(a);
' Create, initialize, and set the value of a to 15.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 15UI)

' Assert that the Kronecker symbol of (a/4) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) = 1)

' Release unmanaged memory allocated for a.
gmp_lib.mpz_clear(a)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_kronecker
mpz_kronecker_ui
mpz_legendre
mpz_si_kronecker
mpz_ui_kronecker


gmp_lib.mpz_kronecker_ui Method

gmp_libmpz_kronecker_ui Method
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_kronecker_ui(
    mpz_t a,
    uint b
)
Public Shared Function mpz_kronecker_ui (
    a As mpz_t,
    b As UInteger
) As Integer
public:
static int mpz_kronecker_ui(
    mpz_t^ a,
    unsigned int b
)
static member mpz_kronecker_ui :
        a : mpz_t *
        b : uint32 -> int

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
b
Type: SystemUInt32
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Remarks

When b is odd the Jacobi symbol and Kronecker symbol are identical, so mpz_kronecker_ui, etc. can be used for mixed precision Jacobi symbols too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of a to 15.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 15U);

// Assert that the Kronecker symbol of (a/4) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4U) == 1);

// Release unmanaged memory allocated for a.
gmp_lib.mpz_clear(a);
' Create, initialize, and set the value of a to 15.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 15UI)

' Assert that the Kronecker symbol of (a/4) is 1.
Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4UI) = 1)

' Release unmanaged memory allocated for a.
gmp_lib.mpz_clear(a)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_kronecker
mpz_kronecker_si
mpz_legendre
mpz_si_kronecker
mpz_ui_kronecker


gmp_lib.mpz_lcm Method

gmp_libmpz_lcm Method
Set rop to the least common multiple of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_lcm(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_lcm (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_lcm(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_lcm :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

rop is always positive, irrespective of the signs of op1 and op2. rop will be zero if either op1 or op2 is zero.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 2.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 2U);

// Create, initialize, and set the value of op2 to 3.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 3U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the least common multiple of op1 and op2.
gmp_lib.mpz_lcm(rop, op1, op2);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 2.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 2UI)

' Create, initialize, and set the value of op2 to 3.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 3UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the least common multiple of op1 and op2.
gmp_lib.mpz_lcm(rop, op1, op2)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_lcm_ui


gmp_lib.mpz_lcm_ui Method

gmp_libmpz_lcm_ui Method
Set rop to the least common multiple of op1 and op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_lcm_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_lcm_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_lcm_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_lcm_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Remarks

rop is always positive, irrespective of the signs of op1 and op2. rop will be zero if either op1 or op2 is zero.

Examples
C#
VB
C++
F#
Copy
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
Reference
gmp_lib Class
Math.Gmp.Native Namespace
mpz_lcm


gmp_lib.mpz_legendre Method

gmp_libmpz_legendre Method
Calculate the Legendre symbol (a/p).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_legendre(
    mpz_t a,
    mpz_t p
)
Public Shared Function mpz_legendre (
    a As mpz_t,
    p As mpz_t
) As Integer
public:
static int mpz_legendre(
    mpz_t^ a,
    mpz_t^ p
)
static member mpz_legendre :
        a : mpz_t *
        p : mpz_t -> int

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
p
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Legendre symbol (a/p).
Remarks

This is defined only for p an odd positive prime, and for such p it’s identical to the Jacobi symbol.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of a to 20.
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 20U);

// Create, initialize, and set the value of p to 11.
mpz_t p = new mpz_t();
gmp_lib.mpz_init_set_ui(p, 11U);

// Assert that the Legendre symbol of (a/p) is 1.
Assert.IsTrue(gmp_lib.mpz_legendre(a, p) == 1);

// Release unmanaged memory allocated for a and p.
gmp_lib.mpz_clears(a, p, null);
' Create, initialize, and set the value of a to 20.
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 20UI)

' Create, initialize, and set the value of p to 11.
Dim p As New mpz_t()
gmp_lib.mpz_init_set_ui(p, 11UI)

' Assert that the Legendre symbol of (a/p) is 1.
Assert.IsTrue(gmp_lib.mpz_legendre(a, p) = 1)

' Release unmanaged memory allocated for a and p.
gmp_lib.mpz_clears(a, p, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_jacobi


gmp_lib.mpz_limbs_finish Method

gmp_libmpz_limbs_finish Method
Updates the internal size field of x.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_limbs_finish(
    mpz_t x,
    mp_size_t s
)
Public Shared Sub mpz_limbs_finish (
    x As mpz_t,
    s As mp_size_t
)
public:
static void mpz_limbs_finish(
    mpz_t^ x,
    mp_size_t s
)
static member mpz_limbs_finish :
        x : mpz_t *
        s : mp_size_t -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
The operand integer.
s
Type: Math.Gmp.Nativemp_size_t
The number of limbs and the sign of x.
Remarks

Used after writing to the limb array pointer returned by mpz_limbs_write or mpz_limbs_modify is completed. The array should contain | s | valid limbs, representing the new absolute value for x, and the sign of x is taken from the sign of s. This function never reallocates x, so the limb pointer remains valid.

C++
Copy
void foo (mpz_t x)
{
    mp_size_t n, i;
    mp_limb_t* xp;

    n = mpz_size(x);
    xp = mpz_limbs_modify(x, 2 * n);
    for (i = 0; i < n; i++)
        xp[n + i] = xp[n - 1 - i];
    mpz_limbs_finish(x, mpz_sgn(x) < 0 ? - 2 * n : 2 * n);
}
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_size
mpz_limbs_read
mpz_limbs_write
mpz_limbs_modify
mpz_roinit_n


gmp_lib.mpz_limbs_modify Method

gmp_libmpz_limbs_modify Method
Return a pointer to the limb array of x, intended for write access.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_ptr mpz_limbs_modify(
    mpz_t x,
    mp_size_t n
)
Public Shared Function mpz_limbs_modify (
    x As mpz_t,
    n As mp_size_t
) As mp_ptr
public:
static mp_ptr^ mpz_limbs_modify(
    mpz_t^ x,
    mp_size_t n
)
static member mpz_limbs_modify :
        x : mpz_t *
        n : mp_size_t -> mp_ptr

Parameters

x
Type: Math.Gmp.Nativempz_t
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs.

Return Value

Type: mp_ptr
A pointer to the limb array of x, intended for write access.
Remarks

The array is reallocated as needed, to make room for n limbs. Requires n > 0. The mpz_limbs_modify function returns an array that holds the old absolute value of x

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 2.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 2U);

// Resize x to 3 limbs, and get pointer to the limbs.
mp_ptr limbs = gmp_lib.mpz_limbs_modify(x, 3);

// Set the value of x.
limbs[0] = 0;
limbs[1] = 0;
limbs[2] = (IntPtr.Size == 4 ? 8U : 64U);
gmp_lib.mpz_limbs_finish(x, -3);

// Assert the value of x based on current architecture (x86 or x64).
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x);
Assert.IsTrue(s.ToString() == "-1000 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""));

// Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x);
gmp_lib.free(s);
' Create, initialize, and set the value of x to 2.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 2UI)

' Resize x to 3 limbs, and get pointer to the limbs.
Dim limbs As mp_ptr = gmp_lib.mpz_limbs_modify(x, 3)

' Set the value of x.
limbs(0) = 0
limbs(1) = 0
limbs(2) = (If(IntPtr.Size = 4, 8UI, 64UI))
gmp_lib.mpz_limbs_finish(x, -3)

' Assert the value of x based on current architecture (x86 or x64).
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x)
Assert.IsTrue(s.ToString() = "-1000 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""))

' Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_size
mpz_limbs_read
mpz_limbs_write
mpz_limbs_finish
mpz_roinit_n


gmp_lib.mpz_limbs_read Method

gmp_libmpz_limbs_read Method
Return a pointer to the limb array representing the absolute value of x.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_ptr mpz_limbs_read(
    mpz_t x
)
Public Shared Function mpz_limbs_read (
    x As mpz_t
) As mp_ptr
public:
static mp_ptr^ mpz_limbs_read(
    mpz_t^ x
)
static member mpz_limbs_read :
        x : mpz_t -> mp_ptr

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: mp_ptr
A pointer to the limb array representing the absolute value of x.
Remarks

The size of the array is mpz_size(x). Intended for read access only.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x.
char_ptr value = new char_ptr("10000 00000000000000000000000000000000");
gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4);

// Get pointer to the limbs of x.
mp_ptr limbs = gmp_lib.mpz_limbs_read(x);

// Assert the values of the limbs based on current architecture (x86 or x64).
Assert.IsTrue(limbs[0] == 0);
Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U));

// Release unmanaged memory allocated for x and value.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
' Create and initialize new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x.
Dim value As New char_ptr("10000 00000000000000000000000000000000")
gmp_lib.mpz_set_str(x, value, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4))

' Get pointer to the limbs of x.
Dim limbs As mp_ptr = gmp_lib.mpz_limbs_read(x)

' Assert the values of the limbs based on current architecture (x86 or x64).
Assert.IsTrue(limbs(0) = 0)
Assert.IsTrue(limbs(1) = (If(gmp_lib.mp_bytes_per_limb = 4, 16UI, 256UI)))

' Release unmanaged memory allocated for x and value.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_size
mpz_limbs_write
mpz_limbs_modify
mpz_limbs_finish
mpz_roinit_n


gmp_lib.mpz_limbs_write Method

gmp_libmpz_limbs_write Method
Return a pointer to the limb array of x, intended for write access.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_ptr mpz_limbs_write(
    mpz_t x,
    mp_size_t n
)
Public Shared Function mpz_limbs_write (
    x As mpz_t,
    n As mp_size_t
) As mp_ptr
public:
static mp_ptr^ mpz_limbs_write(
    mpz_t^ x,
    mp_size_t n
)
static member mpz_limbs_write :
        x : mpz_t *
        n : mp_size_t -> mp_ptr

Parameters

x
Type: Math.Gmp.Nativempz_t
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs.

Return Value

Type: mp_ptr
A pointer to the limb array of x, intended for write access.
Remarks

The array is reallocated as needed, to make room for n limbs. Requires n > 0. The mpz_limbs_write function may destroy the old value and return an array with unspecified contents.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Resize x to 3 limbs, and get pointer to the limbs.
gmp_lib.mpz_set_ui(x, 2U);
mp_ptr limbs = gmp_lib.mpz_limbs_write(x, 3);

// Set the values of the limbs.
limbs[0] = 0U;
limbs[1] = 0U;
limbs[2] = (gmp_lib.mp_bytes_per_limb == 4 ? 2U : 4U);
gmp_lib.mpz_limbs_finish(x, -3);

// Assert the value of x based on current architecture (x86 or x64).
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x);
Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""));

// Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x);
gmp_lib.free(s);
' Create and initialize new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Resize x to 3 limbs, and get pointer to the limbs.
gmp_lib.mpz_set_ui(x, 2UI)
Dim limbs As mp_ptr = gmp_lib.mpz_limbs_write(x, 3)

' Set the values of the limbs.
limbs(0) = 0UI
limbs(1) = 0UI
limbs(2) = (If(gmp_lib.mp_bytes_per_limb = 4, 2UI, 4UI))
gmp_lib.mpz_limbs_finish(x, -3)

' Assert the value of x based on current architecture (x86 or x64).
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x)
Assert.IsTrue(s.ToString() = "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""))

' Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_size
mpz_limbs_read
mpz_limbs_modify
mpz_limbs_finish
mpz_roinit_n


gmp_lib.mpz_lucnum_ui Method

gmp_libmpz_lucnum_ui Method
Sets ln to to L[n], the n’th Lucas number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_lucnum_ui(
    mpz_t ln,
    uint n
)
Public Shared Sub mpz_lucnum_ui (
    ln As mpz_t,
    n As UInteger
)
public:
static void mpz_lucnum_ui(
    mpz_t^ ln,
    unsigned int n
)
static member mpz_lucnum_ui :
        ln : mpz_t *
        n : uint32 -> unit

Parameters

ln
Type: Math.Gmp.Nativempz_t
The L[n] result.
n
Type: SystemUInt32
The operand integer.
Remarks

The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both mpz_fib2_ui and mpz_lucnum2_ui. The formulas for going from Fibonacci to Lucas can be found in GNU MP - Lucas Numbers Algorithm, the reverse is straightforward too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of ln to 0.
mpz_t ln = new mpz_t();
gmp_lib.mpz_init(ln);

// Set ln to the 9'th Lucas number.
gmp_lib.mpz_lucnum_ui(ln, 9U);

// Assert that ln is 76.
Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76);

// Release unmanaged memory allocated for ln.
gmp_lib.mpz_clear(ln);
' Create, initialize, and set the value of ln to 0.
Dim ln As New mpz_t()
gmp_lib.mpz_init(ln)

' Set ln to the 9'th Lucas number.
gmp_lib.mpz_lucnum_ui(ln, 9UI)

' Assert that ln is 76.
Assert.IsTrue(gmp_lib.mpz_get_si(ln) = 76)

' Release unmanaged memory allocated for ln.
gmp_lib.mpz_clear(ln)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_lucnum2_ui


gmp_lib.mpz_lucnum2_ui Method

gmp_libmpz_lucnum2_ui Method
Sets ln to L[n], and lnsub1 to L[n - 1].

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_lucnum2_ui(
    mpz_t ln,
    mpz_t lnsub1,
    uint n
)
Public Shared Sub mpz_lucnum2_ui (
    ln As mpz_t,
    lnsub1 As mpz_t,
    n As UInteger
)
public:
static void mpz_lucnum2_ui(
    mpz_t^ ln,
    mpz_t^ lnsub1,
    unsigned int n
)
static member mpz_lucnum2_ui :
        ln : mpz_t *
        lnsub1 : mpz_t *
        n : uint32 -> unit

Parameters

ln
Type: Math.Gmp.Nativempz_t
The L[n] result.
lnsub1
Type: Math.Gmp.Nativempz_t
The L[n - 1] result.
n
Type: SystemUInt32
The operand integer.
Remarks

This function is designed for calculating isolated Lucas numbers. When a sequence of values is wanted it’s best to start with mpz_lucnum2_ui and iterate the defining L[n + 1] = L[n] + L[n - 1] or similar.

The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both mpz_fib2_ui and mpz_lucnum2_ui. The formulas for going from Fibonacci to Lucas can be found in GNU MP - Lucas Numbers Algorithm, the reverse is straightforward too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the values of lnsub1 and ln to 0.
mpz_t ln = new mpz_t();
mpz_t lnsub1 = new mpz_t();
gmp_lib.mpz_inits(ln, lnsub1, null);

// Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively.
gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9U);

// Assert that lnsub1 and ln are respectively 47 and 76.
Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) == 47);
Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76);

// Release unmanaged memory allocated for ln and lnsub1.
gmp_lib.mpz_clears(ln, lnsub1, null);
' Create, initialize, and set the values of lnsub1 and ln to 0.
Dim ln As New mpz_t()
Dim lnsub1 As New mpz_t()
gmp_lib.mpz_inits(ln, lnsub1, Nothing)

' Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively.
gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9UI)

' Assert that lnsub1 and ln are respectively 47 and 76.
Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) = 47)
Assert.IsTrue(gmp_lib.mpz_get_si(ln) = 76)

' Release unmanaged memory allocated for ln and lnsub1.
gmp_lib.mpz_clears(ln, lnsub1, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_lucnum_ui


gmp_lib.mpz_mfac_uiui Method

gmp_libmpz_mfac_uiui Method
Set rop to the m-multi-factorial n!^(m)n.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mfac_uiui(
    mpz_t rop,
    uint n,
    uint m
)
Public Shared Sub mpz_mfac_uiui (
    rop As mpz_t,
    n As UInteger,
    m As UInteger
)
public:
static void mpz_mfac_uiui(
    mpz_t^ rop,
    unsigned int n,
    unsigned int m
)
static member mpz_mfac_uiui :
        rop : mpz_t *
        n : uint32 *
        m : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: SystemUInt32
The first operand integer.
m
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = 10!^(4).
gmp_lib.mpz_mfac_uiui(rop, 10U, 4U);

// Assert that rop is 945.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 120);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = 10!^(4).
gmp_lib.mpz_mfac_uiui(rop, 10UI, 4UI)

' Assert that rop is 945.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 120)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fac_ui
mpz_2fac_ui


gmp_lib.mpz_millerrabin Method

gmp_libmpz_millerrabin Method
An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_millerrabin(
    mpz_t n,
    int reps
)
Public Shared Function mpz_millerrabin (
    n As mpz_t,
    reps As Integer
) As Integer
public:
static int mpz_millerrabin(
    mpz_t^ n,
    int reps
)
static member mpz_millerrabin :
        n : mpz_t *
        reps : int -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
The operand integer.
reps
Type: SystemInt32
The number of internal passes of the probabilistic algorithm.

Return Value

Type: Int32
If the function mpz_millerrabin returns 0 then n is not prime. If it returns 1, then n is 'probably' prime.
Remarks

The probability of a false positive is (1/4)^reps, where reps is the number of internal passes of the probabilistic algorithm. Knuth indicates that 25 passes are reasonable.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 12.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_ui(n, 12U);

// Assert that n is a composite number.
Assert.IsTrue(gmp_lib.mpz_millerrabin(n, 25) == 0);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 12.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 12UI)

' Assert that n is a composite number.
Assert.IsTrue(gmp_lib.mpz_millerrabin(n, 25) = 0)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_probab_prime_p


gmp_lib.mpz_mod Method

gmp_libmpz_mod Method
Set r to n mod d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mod(
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_mod (
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_mod(
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_mod :
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Remarks

The sign of the divisor is ignored; the result is always non-negative.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 12222.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 12222U);

// Create, initialize, and set the value of y to 10000.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 10000U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x mod y.
gmp_lib.mpz_mod(z, x, y);

// Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 12222.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 12222UI)

' Create, initialize, and set the value of y to 10000.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 10000UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x mod y.
gmp_lib.mpz_mod(z, x, y)

' Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 12222 Mod 10000)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod_ui
mpz_tdiv_qr


gmp_lib.mpz_mod_ui Method

gmp_libmpz_mod_ui Method
Set r to n mod d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_mod_ui(
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_mod_ui (
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_mod_ui(
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_mod_ui :
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
The remainder r.
Remarks

The sign of the divisor is ignored; the result is always non-negative.

mpz_mod_ui is identical to mpz_fdiv_r_ui, returning the remainder as well as setting r. See mpz_fdiv_ui if only the return value is wanted.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 12222.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 12222U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x mod y, and return z.
Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000U) == 12222 % 10000);

// Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to 12222.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 12222UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x mod y, and return z.
Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000UI) = 12222 Mod 10000)

' Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 12222 Mod 10000)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_qr


gmp_lib.mpz_mul Method

gmp_libmpz_mul Method
Set rop to op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mul(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_mul (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_mul(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_mul :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 12222.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 12222U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x * y.
gmp_lib.mpz_mul(z, x, y);

// Assert that z is the product of x and y.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000 * 12222);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 12222.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 12222UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x * y.
gmp_lib.mpz_mul(z, x, y)

' Assert that z is the product of x and y.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000 * 12222)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul_2exp
mpz_mul_si
mpz_mul_ui
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_mul_2exp Method

gmp_libmpz_mul_2exp Method
Set rop to op1 * 2^op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mul_2exp(
    mpz_t rop,
    mpz_t op1,
    mp_bitcnt_t op2
)
Public Shared Sub mpz_mul_2exp (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mp_bitcnt_t
)
public:
static void mpz_mul_2exp(
    mpz_t^ rop,
    mpz_t^ op1,
    mp_bitcnt_t op2
)
static member mpz_mul_2exp :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativemp_bitcnt_t
The second operand integer.
Remarks

This operation can also be defined as a left shift by op2 bits.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of x to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = -10000 * 2^2.
gmp_lib.mpz_mul_2exp(z, x, 2U);

// Assert that z is -40000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 4);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of x to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = -10000 * 2^2.
gmp_lib.mpz_mul_2exp(z, x, 2UI)

' Assert that z is -40000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 4)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_mul_si
mpz_mul_ui
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_mul_si Method

gmp_libmpz_mul_si Method
Set rop to op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mul_si(
    mpz_t rop,
    mpz_t op1,
    int op2
)
Public Shared Sub mpz_mul_si (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As Integer
)
public:
static void mpz_mul_si(
    mpz_t^ rop,
    mpz_t^ op1,
    int op2
)
static member mpz_mul_si :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : int -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x * 12222.
gmp_lib.mpz_mul_si(z, x, 12222);

// Assert that z is the product of x and 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x * 12222.
gmp_lib.mpz_mul_si(z, x, 12222)

' Assert that z is the product of x and 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 12222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_mul_2exp
mpz_mul_ui
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_mul_ui Method

gmp_libmpz_mul_ui Method
Set rop to op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_mul_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_mul_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_mul_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_mul_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x * 12222.
gmp_lib.mpz_mul_ui(z, x, 12222);

// Assert that z is the product of x and 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x * 12222.
gmp_lib.mpz_mul_ui(z, x, 12222)

' Assert that z is the product of x and 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 12222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_mul_2exp
mpz_mul_si
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_neg Method

gmp_libmpz_neg Method
Set rop to -op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_neg(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_neg (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_neg(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_neg :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = -x.
gmp_lib.mpz_neg(z, x);

// Assert that z is -x.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = -x.
gmp_lib.mpz_neg(z, x)

' Assert that z is -x.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_nextprime Method

gmp_libmpz_nextprime Method
Set rop to the next prime greater than op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_nextprime(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_nextprime (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_nextprime(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_nextprime :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result prime integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks

This function uses a probabilistic algorithm to identify primes. For practical purposes it’s adequate, the chance of a composite passing will be extremely small.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 12.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 12U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the next following op.
gmp_lib.mpz_nextprime(rop, op);

// Assert that rop is 13.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 13);

// Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of n to 12.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 12UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the next following op.
gmp_lib.mpz_nextprime(rop, op)

' Assert that rop is 13.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 13)

' Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_probab_prime_p


gmp_lib.mpz_odd_p Method

gmp_libmpz_odd_p Method
Determine whether op is odd.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_odd_p(
    mpz_t op
)
Public Shared Function mpz_odd_p (
    op As mpz_t
) As Integer
public:
static int mpz_odd_p(
    mpz_t^ op
)
static member mpz_odd_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return non-zero if odd, zero if even.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 427294.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 427294);

// Assert that op is not odd but even.
Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0);
Assert.IsTrue(gmp_lib.mpz_odd_p(op) == 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 427294.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 427294)

' Assert that op is not odd but even.
Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0)
Assert.IsTrue(gmp_lib.mpz_odd_p(op) = 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_even_p
mpz_sizeinbase


gmp_lib.mpz_out_raw Method

gmp_libmpz_out_raw Method
Output op on stdio stream stream, in raw binary format.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpz_out_raw(
    ptr<FILE> stream,
    mpz_t op
)
Public Shared Function mpz_out_raw (
    stream As ptr(Of FILE),
    op As mpz_t
) As size_t
public:
static size_t mpz_out_raw(
    ptr<FILE>^ stream,
    mpz_t^ op
)
static member mpz_out_raw :
        stream : ptr<FILE> *
        op : mpz_t -> size_t

Parameters

stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file streama.
op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: size_t
Return the number of bytes written, or if an error occurred, return 0.
Remarks

The integer is written in a portable format, with 4 bytes of size information, and that many bytes of limbs. Both the size and the limbs are written in decreasing significance order (i.e., in big-endian).

The output can be read with mpz_inp_raw.

The output of this can not be read by mpz_inp_raw from GMP 1, because of changes necessary for compatibility between 32-bit and 64-bit machines.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123456 (0x1E240).
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 0x1E240);

// Get a temporary file.
string pathname = System.IO.Path.GetTempFileName();

// Open temporary file for writing.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");

// Write op to temporary file, and assert that the number of bytes written is 7.
Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7);

// Close temporary file.
fclose(stream.Value.Value);

// Assert that the content of the temporary file.
byte[] r = System.IO.File.ReadAllBytes(pathname);
Assert.IsTrue(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 3 && r[4] == 0x01 && r[5] == 0xE2 && r[6] == 0x40);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 123456 (0x1E240).
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, &H1e240)

' Get a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()

' Open temporary file for writing.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "w")

' Write op to temporary file, and assert that the number of bytes written is 7.
Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) = 7)

' Close temporary file.
fclose(stream.Value.Value)

' Assert that the content of the temporary file.
Dim r As Byte() = System.IO.File.ReadAllBytes(pathname)
Assert.IsTrue(r(0) = 0 AndAlso r(1) = 0 AndAlso r(2) = 0 AndAlso r(3) = 3 AndAlso r(4) = &H1 AndAlso r(5) = &He2 AndAlso r(6) = &H40)

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_out_str
mpz_inp_str
mpz_inp_raw


gmp_lib.mpz_out_str Method

gmp_libmpz_out_str Method
Output op on stdio stream stream, as a string of digits in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpz_out_str(
    ptr<FILE> stream,
    int base,
    mpz_t op
)
Public Shared Function mpz_out_str (
    stream As ptr(Of FILE),
    base As Integer,
    op As mpz_t
) As size_t
public:
static size_t mpz_out_str(
    ptr<FILE>^ stream,
    int base,
    mpz_t^ op
)
static member mpz_out_str :
        stream : ptr<FILE> *
        base : int *
        op : mpz_t -> size_t

Parameters

stream
Type: Math.Gmp.Nativeptr FILE
Pointer to file stream.
base
Type: SystemInt32
The base operand.
op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: size_t
Return the number of bytes written, or if an error occurred, return 0.
Remarks

The base argument may vary from 2 to 62 or from -2 to -36.

For base in the range 2..36, digits and lower-case letters are used; for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 123456.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 123456U);

// Get a temporary file.
string pathname = System.IO.Path.GetTempFileName();

// Open temporary file for writing.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");

// Write op to temporary file, and assert that the number of bytes written is 6.
Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) == 6);

// Close temporary file.
fclose(stream.Value.Value);

// Assert that the content of the temporary file is "123456".
string result = System.IO.File.ReadAllText(pathname);
Assert.IsTrue(result == "123456");

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 123456.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 123456UI)

' Get a temporary file.
Dim pathname As String = System.IO.Path.GetTempFileName()

' Open temporary file for writing.
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "w")

' Write op to temporary file, and assert that the number of bytes written is 6.
Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) = 6)

' Close temporary file.
fclose(stream.Value.Value)

' Assert that the content of the temporary file is "123456".
Dim result As String = System.IO.File.ReadAllText(pathname)
Assert.IsTrue(result = "123456")

' Delete temporary file.
System.IO.File.Delete(pathname)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_inp_str
mpz_out_raw
mpz_inp_raw


gmp_lib.mpz_perfect_power_p Method

gmp_libmpz_perfect_power_p Method
Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_perfect_power_p(
    mpz_t op
)
Public Shared Function mpz_perfect_power_p (
    op As mpz_t
) As Integer
public:
static int mpz_perfect_power_p(
    mpz_t^ op
)
static member mpz_perfect_power_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
Remarks

Under this definition both 0 and 1 are considered to be perfect powers. Negative values of op are accepted, but of course can only be odd perfect powers.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Assert that op is a perfect power.
Assert.IsTrue(gmp_lib.mpz_perfect_power_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of x to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Assert that op is a perfect power.
Assert.IsTrue(gmp_lib.mpz_perfect_power_p(op) > 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_square_p
mpz_root
mpz_rootrem
mpz_sqrt
mpz_sqrtrem


gmp_lib.mpz_perfect_square_p Method

gmp_libmpz_perfect_square_p Method
Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_perfect_square_p(
    mpz_t op
)
Public Shared Function mpz_perfect_square_p (
    op As mpz_t
) As Integer
public:
static int mpz_perfect_square_p(
    mpz_t^ op
)
static member mpz_perfect_square_p :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Non-zero if op is a perfect square, i.e., if the square root of op is an integer.
Remarks

Under this definition both 0 and 1 are considered to be perfect squares.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Assert that op is a perfect square.
Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of x to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Assert that op is a perfect square.
Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_power_p
mpz_root
mpz_rootrem
mpz_sqrt
mpz_sqrtrem


gmp_lib.mpz_popcount Method

gmp_libmpz_popcount Method
Return the population count of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpz_popcount(
    mpz_t op
)
Public Shared Function mpz_popcount (
    op As mpz_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_popcount(
    mpz_t^ op
)
static member mpz_popcount :
        op : mpz_t -> mp_bitcnt_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: mp_bitcnt_t
If op ≥ 0, return the population count of op, which is the number of 1 bits in the binary representation. If op < 0, the number of 1s is infinite, and the return value is the largest possible mp_bitcnt_t.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 63.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 63U);

// Assert that op has 6 one bits.
Assert.IsTrue(gmp_lib.mpz_popcount(op) == 6U);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clears(op);
' Create, initialize, and set the value of op to 63.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 63UI)

' Assert that op has 6 one bits.
Assert.IsTrue(gmp_lib.mpz_popcount(op) = 6UI)

' Release unmanaged memory allocated for op.

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_pow_ui Method

gmp_libmpz_pow_ui Method
Set rop to base^exp. The case 0^0 yields 1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_pow_ui(
    mpz_t rop,
    mpz_t base,
    uint exp
)
Public Shared Sub mpz_pow_ui (
    rop As mpz_t,
    base As mpz_t,
    exp As UInteger
)
public:
static void mpz_pow_ui(
    mpz_t^ rop,
    mpz_t^ base,
    unsigned int exp
)
static member mpz_pow_ui :
        rop : mpz_t *
        base : mpz_t *
        exp : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
base
Type: Math.Gmp.Nativempz_t
The base integer.
exp
Type: SystemUInt32
The exponent integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of base to 2.
mpz_t @base = new mpz_t();
gmp_lib.mpz_init_set_ui(@base, 2U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = base^4.
gmp_lib.mpz_pow_ui(rop, @base, 4U);

// Assert that rop is 16.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16);

// Release unmanaged memory allocated for rop and base.
gmp_lib.mpz_clears(rop, @base, null);
' Create, initialize, and set the value of base to 2.
Dim base As New mpz_t()
gmp_lib.mpz_init_set_ui(base, 2UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = base^4.
gmp_lib.mpz_pow_ui(rop, base, 4UI)

' Assert that rop is 16.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 16)

' Release unmanaged memory allocated for rop and base.
gmp_lib.mpz_clears(rop, base, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_powm
mpz_powm_ui
mpz_powm_sec
mpz_ui_pow_ui


gmp_lib.mpz_powm Method

gmp_libmpz_powm Method
Set rop to (base^exp) modulo mod.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_powm(
    mpz_t rop,
    mpz_t base,
    mpz_t exp,
    mpz_t mod
)
Public Shared Sub mpz_powm (
    rop As mpz_t,
    base As mpz_t,
    exp As mpz_t,
    mod As mpz_t
)
public:
static void mpz_powm(
    mpz_t^ rop,
    mpz_t^ base,
    mpz_t^ exp,
    mpz_t^ mod
)
static member mpz_powm :
        rop : mpz_t *
        base : mpz_t *
        exp : mpz_t *
        mod : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
base
Type: Math.Gmp.Nativempz_t
The base integer.
exp
Type: Math.Gmp.Nativempz_t
The exponent integer.
mod
Type: Math.Gmp.Nativempz_t
The modulo integer.
Remarks

Negative exp is supported if an inverse base^-1 modulo mod exists (see mpz_invert). If an inverse doesn’t exist then a divide by zero is raised.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of base to 2.
mpz_t @base = new mpz_t();
gmp_lib.mpz_init_set_ui(@base, 2U);

// Create, initialize, and set the value of exp to 4.
mpz_t exp = new mpz_t();
gmp_lib.mpz_init_set_ui(exp, 4U);

// Create, initialize, and set the value of mod to 3.
mpz_t mod = new mpz_t();
gmp_lib.mpz_init_set_ui(mod, 3U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = base^exp mod mod.
gmp_lib.mpz_powm(rop, @base, exp, mod);

// Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1);

// Release unmanaged memory allocated for rop, base, exp, and mod.
gmp_lib.mpz_clears(rop, @base, exp, mod, null);
' Create, initialize, and set the value of base to 2.
Dim base As New mpz_t()
gmp_lib.mpz_init_set_ui(base, 2UI)

' Create, initialize, and set the value of exp to 4.
Dim exp As New mpz_t()
gmp_lib.mpz_init_set_ui(exp, 4UI)

' Create, initialize, and set the value of mod to 3.
Dim[mod] As New mpz_t()
gmp_lib.mpz_init_set_ui([mod], 3UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = base^exp mod mod.
gmp_lib.mpz_powm(rop, base, exp, [mod])

' Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1)

' Release unmanaged memory allocated for rop, base, exp, and mod.
gmp_lib.mpz_clears(rop, base, exp, [mod], Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_powm_ui
mpz_powm_sec
mpz_pow_ui
mpz_ui_pow_ui


gmp_lib.mpz_powm_sec Method

gmp_libmpz_powm_sec Method
Set rop to (base^exp) modulo mod.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_powm_sec(
    mpz_t rop,
    mpz_t base,
    mpz_t exp,
    mpz_t mod
)
Public Shared Sub mpz_powm_sec (
    rop As mpz_t,
    base As mpz_t,
    exp As mpz_t,
    mod As mpz_t
)
public:
static void mpz_powm_sec(
    mpz_t^ rop,
    mpz_t^ base,
    mpz_t^ exp,
    mpz_t^ mod
)
static member mpz_powm_sec :
        rop : mpz_t *
        base : mpz_t *
        exp : mpz_t *
        mod : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
base
Type: Math.Gmp.Nativempz_t
The base integer.
exp
Type: Math.Gmp.Nativempz_t
The exponent integer.
mod
Type: Math.Gmp.Nativempz_t
The modulo integer.
Remarks

It is required that exp > 0 and that mod is odd.

This function is designed to take the same time and have the same cache access patterns for any two same-size arguments, assuming that function arguments are placed at the same position and that the machine state is identical upon function entry. This function is intended for cryptographic purposes, where resilience to side-channel attacks is desired.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of base to 2.
mpz_t @base = new mpz_t();
gmp_lib.mpz_init_set_ui(@base, 2U);

// Create, initialize, and set the value of exp to 4.
mpz_t exp = new mpz_t();
gmp_lib.mpz_init_set_ui(exp, 4U);

// Create, initialize, and set the value of mod to 3.
mpz_t mod = new mpz_t();
gmp_lib.mpz_init_set_ui(mod, 3U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = base^exp mod mod.
gmp_lib.mpz_powm_sec(rop, @base, exp, mod);

// Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1);

// Release unmanaged memory allocated for rop, base, exp, and mod.
gmp_lib.mpz_clears(rop, @base, exp, mod, null);
' Create, initialize, and set the value of base to 2.
Dim base As New mpz_t()
gmp_lib.mpz_init_set_ui(base, 2UI)

' Create, initialize, and set the value of exp to 4.
Dim exp As New mpz_t()
gmp_lib.mpz_init_set_ui(exp, 4UI)

' Create, initialize, and set the value of mod to 3.
Dim[mod] As New mpz_t()
gmp_lib.mpz_init_set_ui([mod], 3UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = base^exp mod mod.
gmp_lib.mpz_powm_sec(rop, base, exp, [mod])

' Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1)

' Release unmanaged memory allocated for rop, base, exp, and mod.
gmp_lib.mpz_clears(rop, base, exp, [mod], Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_powm
mpz_powm_ui
mpz_pow_ui
mpz_ui_pow_ui


gmp_lib.mpz_powm_ui Method

gmp_libmpz_powm_ui Method
Set rop to (base^exp) modulo mod.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_powm_ui(
    mpz_t rop,
    mpz_t base,
    uint exp,
    mpz_t mod
)
Public Shared Sub mpz_powm_ui (
    rop As mpz_t,
    base As mpz_t,
    exp As UInteger,
    mod As mpz_t
)
public:
static void mpz_powm_ui(
    mpz_t^ rop,
    mpz_t^ base,
    unsigned int exp,
    mpz_t^ mod
)
static member mpz_powm_ui :
        rop : mpz_t *
        base : mpz_t *
        exp : uint32 *
        mod : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
base
Type: Math.Gmp.Nativempz_t
The base integer.
exp
Type: SystemUInt32
The exponent integer.
mod
Type: Math.Gmp.Nativempz_t
The modulo integer.
Remarks

Negative exp is supported if an inverse base^-1 modulo mod exists (see mpz_invert). If an inverse doesn’t exist then a divide by zero is raised.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of base to 2.
mpz_t @base = new mpz_t();
gmp_lib.mpz_init_set_ui(@base, 2U);

mpz_t mod = new mpz_t();
gmp_lib.mpz_init_set_ui(mod, 3U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = base^4 mod mod.
gmp_lib.mpz_powm_ui(rop, @base, 4U, mod);

// Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1);

// Release unmanaged memory allocated for rop, base, and mod.
gmp_lib.mpz_clears(rop, @base, mod, null);
' Create, initialize, and set the value of base to 2.
Dim base As New mpz_t()
gmp_lib.mpz_init_set_ui(base, 2UI)
Dim[mod] As New mpz_t()
gmp_lib.mpz_init_set_ui([mod], 3UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = base^4 mod mod.
gmp_lib.mpz_powm_ui(rop, base, 4UI, [mod])

' Assert that rop is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1)

' Release unmanaged memory allocated for rop, base, and mod.
gmp_lib.mpz_clears(rop, base, [mod], Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_powm
mpz_powm_sec
mpz_pow_ui
mpz_ui_pow_ui


gmp_lib.mpz_primorial_ui Method

gmp_libmpz_primorial_ui Method
Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_primorial_ui(
    mpz_t rop,
    uint n
)
Public Shared Sub mpz_primorial_ui (
    rop As mpz_t,
    n As UInteger
)
public:
static void mpz_primorial_ui(
    mpz_t^ rop,
    unsigned int n
)
static member mpz_primorial_ui :
        rop : mpz_t *
        n : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: SystemUInt32
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = 7 * 5 * 3 * 2 = 210.
gmp_lib.mpz_primorial_ui(rop, 9U);

// Assert that rop is 210.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 210);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = 7 * 5 * 3 * 2 = 210.
gmp_lib.mpz_primorial_ui(rop, 9UI)

' Assert that rop is 210.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 210)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpz_probab_prime_p Method

gmp_libmpz_probab_prime_p Method
Determine whether n is prime.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_probab_prime_p(
    mpz_t n,
    int reps
)
Public Shared Function mpz_probab_prime_p (
    n As mpz_t,
    reps As Integer
) As Integer
public:
static int mpz_probab_prime_p(
    mpz_t^ n,
    int reps
)
static member mpz_probab_prime_p :
        n : mpz_t *
        reps : int -> int

Parameters

n
Type: Math.Gmp.Nativempz_t
The operand integer.
reps
Type: SystemInt32
The number of Miller-Rabin probabilistic primality tests to perform.

Return Value

Type: Int32
Return 2 if n is definitely prime, return 1 if n is probably prime (without being certain), or return 0 if n is definitely non-prime.
Remarks

This function performs some trial divisions, then reps Miller-Rabin probabilistic primality tests. A higher reps value will reduce the chances of a non-prime being identified as “probably prime”. A composite number will be identified as a prime with a probability of less than 4^(-reps). Reasonable values of reps are between 15 and 50.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 12.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_ui(n, 12U);

// Assert that n is a composite number.
Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) == 0);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 12.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 12UI)

' Assert that n is a composite number.
Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) = 0)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_millerrabin
mpz_nextprime


gmp_lib.mpz_random Method

gmp_libmpz_random Method
Generate a random integer of at most max_size limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_random(
    mpz_t rop,
    mp_size_t max_size
)
Public Shared Sub mpz_random (
    rop As mpz_t,
    max_size As mp_size_t
)
public:
static void mpz_random(
    mpz_t^ rop,
    mp_size_t max_size
)
static member mpz_random :
        rop : mpz_t *
        max_size : mp_size_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
Remarks

The generated random number doesn’t satisfy any particular requirements of randomness. Negative random numbers are generated when max_size is negative.

This function is obsolete. Use mpz_urandomb or mpz_urandomm instead.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer.
gmp_lib.mpz_random(rop, 500);

// Free all memory occupied by state and rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Generate a random integer.
gmp_lib.mpz_random(rop, 500)

' Free all memory occupied by state and rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_urandomb
mpz_urandomm
mpz_rrandomb
mpz_random2


gmp_lib.mpz_random2 Method

gmp_libmpz_random2 Method
Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_random2(
    mpz_t rop,
    mp_size_t max_size
)
Public Shared Sub mpz_random2 (
    rop As mpz_t,
    max_size As mp_size_t
)
public:
static void mpz_random2(
    mpz_t^ rop,
    mp_size_t max_size
)
static member mpz_random2 :
        rop : mpz_t *
        max_size : mp_size_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
Remarks

Useful for testing functions and algorithms, since this kind of random numbers have proven to be more likely to trigger corner-case bugs. Negative random numbers are generated when max_size is negative.

This function is obsolete. Use mpz_rrandomb instead.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer.
gmp_lib.mpz_random(rop, 100);

// Free all memory occupied by rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Generate a random integer.
gmp_lib.mpz_random(rop, 100)

' Free all memory occupied by rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_urandomb
mpz_urandomm
mpz_rrandomb
mpz_random


gmp_lib.mpz_realloc2 Method

gmp_libmpz_realloc2 Method
Change the space allocated for x to n bits.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_realloc2(
    mpz_t x,
    mp_bitcnt_t n
)
Public Shared Sub mpz_realloc2 (
    x As mpz_t,
    n As mp_bitcnt_t
)
public:
static void mpz_realloc2(
    mpz_t^ x,
    mp_bitcnt_t n
)
static member mpz_realloc2 :
        x : mpz_t *
        n : mp_bitcnt_t -> unit

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.
n
Type: Math.Gmp.Nativemp_bitcnt_t
The number of bits.
Remarks

The value in x is preserved if it fits, or is set to 0 if not.

Calling this function is never necessary; reallocation is handled automatically by GMP when needed. But this function can be used to increase the space for a variable in order to avoid repeated automatic reallocations, or to decrease it to give memory back to the heap.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x to a 77-bit integer.
char_ptr value = new char_ptr("1000 0000 0000 0000 0000");
gmp_lib.mpz_set_str(x, value, 16);

// Resize x to 512 bits, and assert that its value has not changed.
gmp_lib.mpz_realloc2(x, 512U);
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x);
Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", ""));

// Resize x to 2 bits, and assert that its value has changed to 0.
gmp_lib.mpz_realloc2(x, 2U);
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
' Create and initialize new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x to a 77-bit integer.
Dim value As New char_ptr("1000 0000 0000 0000 0000")
gmp_lib.mpz_set_str(x, value, 16)

' Resize x to 512 bits, and assert that its value has not changed.
gmp_lib.mpz_realloc2(x, 512UI)
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x)
Assert.IsTrue(s.ToString() = "1000 0000 0000 0000 0000".Replace(" ", ""))

' Resize x to 2 bits, and assert that its value has changed to 0.
gmp_lib.mpz_realloc2(x, 2UI)
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0)

' Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_clear
mpz_clears
mpz_init
mpz_inits
mpz_init2


gmp_lib.mpz_remove Method

gmp_libmpz_remove Method
Remove all occurrences of the factor f from op and store the result in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpz_remove(
    mpz_t rop,
    mpz_t op,
    mpz_t f
)
Public Shared Function mpz_remove (
    rop As mpz_t,
    op As mpz_t,
    f As mpz_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_remove(
    mpz_t^ rop,
    mpz_t^ op,
    mpz_t^ f
)
static member mpz_remove :
        rop : mpz_t *
        op : mpz_t *
        f : mpz_t -> mp_bitcnt_t

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
f
Type: Math.Gmp.Nativempz_t
The factor operand integer.

Return Value

Type: mp_bitcnt_t
The return value is how many such occurrences were removed.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 45.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 45U);

// Create, initialize, and set the value of f to 3.
mpz_t f = new mpz_t();
gmp_lib.mpz_init_set_ui(f, 3U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = op / f^n, and return n, the largest integer greater than or equal to 0, such that f^n divides op.
Assert.IsTrue(gmp_lib.mpz_remove(rop, op, f) == 2);

// Assert that rop is 5.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 5);

// Release unmanaged memory allocated for rop, op, and f.
gmp_lib.mpz_clears(rop, op, f, null);
' Create, initialize, and set the value of op to 45.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 45UI)

' Create, initialize, and set the value of f to 3.
Dim f As New mpz_t()
gmp_lib.mpz_init_set_ui(f, 3UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = op / f^n, and return n, the largest integer greater than or equal to 0, such that f^n divides op.
Assert.IsTrue(gmp_lib.mpz_remove(rop, op, f) = 2)

' Assert that rop is 5.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 5)

' Release unmanaged memory allocated for rop, op, and f.
gmp_lib.mpz_clears(rop, op, f, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mpz_roinit_n Method

gmp_libmpz_roinit_n Method
Special initialization of x, using the given limb array and size.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mpz_t mpz_roinit_n(
    mpz_t x,
    mp_ptr xp,
    mp_size_t xs
)
Public Shared Function mpz_roinit_n (
    x As mpz_t,
    xp As mp_ptr,
    xs As mp_size_t
) As mpz_t
public:
static mpz_t^ mpz_roinit_n(
    mpz_t^ x,
    mp_ptr^ xp,
    mp_size_t xs
)
static member mpz_roinit_n :
        x : mpz_t *
        xp : mp_ptr *
        xs : mp_size_t -> mpz_t

Parameters

x
Type: Math.Gmp.Nativempz_t
The operand integer.
xp
Type: Math.Gmp.Nativemp_ptr
The limbs array.
xs
Type: Math.Gmp.Nativemp_size_t
The number of limbs and the sign.

Return Value

Type: mpz_t
For convenience, the function returns x, but cast to a const pointer type.
Remarks

x should be treated as readonly: it can be passed safely as input to any mpz function, but not as an output. The array xp must point to at least a readable limb, its size is | xs |, and the sign of x is the sign of xs.

C++
Copy
void foo (mpz_t x)
{
    static const mp_limb_t y[3] = { 0x1, 0x2, 0x3 };
    mpz_t tmp;
    mpz_add(x, x, mpz_roinit_n(tmp, y, 3));
}
Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Prepare new limbs for x.
mp_ptr limbs;
if (gmp_lib.mp_bytes_per_limb == 4)
    limbs = new mp_ptr(new uint[] { 0U, 0U, 2U });
else
    limbs = new mp_ptr(new ulong[] { 0UL, 0UL, 4UL });

// Assign new limbs to x, and make x negative.
x = gmp_lib.mpz_roinit_n(x, limbs, -3);

// Assert new value of x.
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x);
Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""));

// Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x);
gmp_lib.free(s);
' Create and initialize new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Prepare new limbs for x.
Dim limbs As mp_ptr
If gmp_lib.mp_bytes_per_limb = 4 Then
    limbs = New mp_ptr(New UInteger() { 0UI, 0UI, 2UI})
Else
    limbs = New mp_ptr(New ULong() { 0UL, 0UL, 4UL})
End If

' Assign new limbs to x, and make x negative.
x = gmp_lib.mpz_roinit_n(x, limbs, -3)

' Assert new value of x.
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x)
Assert.IsTrue(s.ToString() = "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""))

' Release unmanaged memory allocated for x and s.
gmp_lib.mpz_clear(x)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_size
mpz_limbs_read
mpz_limbs_write
mpz_limbs_modify
mpz_limbs_finish


gmp_lib.mpz_root Method

gmp_libmpz_root Method
Set rop to the truncated integer part of the nth root of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_root(
    mpz_t rop,
    mpz_t op,
    uint n
)
Public Shared Function mpz_root (
    rop As mpz_t,
    op As mpz_t,
    n As UInteger
) As Integer
public:
static int mpz_root(
    mpz_t^ rop,
    mpz_t^ op,
    unsigned int n
)
static member mpz_root :
        rop : mpz_t *
        op : mpz_t *
        n : uint32 -> int

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result root integer.
op
Type: Math.Gmp.Nativempz_t
The first operand integer.
n
Type: SystemUInt32
The second operand integer.

Return Value

Type: Int32
Return non-zero if the computation was exact, i.e., if op is rop to the nth power.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = trunc(cbrt(10000)).
gmp_lib.mpz_root(rop, op, 3U);

// Assert that rop is 21.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 21);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of op to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = trunc(cbrt(10000)).
gmp_lib.mpz_root(rop, op, 3UI)

' Assert that rop is 21.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 21)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clears(rop, op, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_power_p
mpz_perfect_square_p
mpz_rootrem
mpz_sqrt
mpz_sqrtrem


gmp_lib.mpz_rootrem Method

gmp_libmpz_rootrem Method
Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_rootrem(
    mpz_t root,
    mpz_t rem,
    mpz_t u,
    uint n
)
Public Shared Sub mpz_rootrem (
    root As mpz_t,
    rem As mpz_t,
    u As mpz_t,
    n As UInteger
)
public:
static void mpz_rootrem(
    mpz_t^ root,
    mpz_t^ rem,
    mpz_t^ u,
    unsigned int n
)
static member mpz_rootrem :
        root : mpz_t *
        rem : mpz_t *
        u : mpz_t *
        n : uint32 -> unit

Parameters

root
Type: Math.Gmp.Nativempz_t
The result root integer.
rem
Type: Math.Gmp.Nativempz_t
The result remainder integer.
u
Type: Math.Gmp.Nativempz_t
The first operand integer.
n
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of u to 10000.
mpz_t u = new mpz_t();
gmp_lib.mpz_init_set_si(u, 10000);

// Create, initialize, and set the values of root and rem to 0.
mpz_t root = new mpz_t();
mpz_t rem = new mpz_t();
gmp_lib.mpz_inits(root, rem, null);

// Set root = trunc(cbrt(10000)) and rem = u - root.
gmp_lib.mpz_rootrem(root, rem, u, 3U);

// Assert that root is 21, and rem is 739.
Assert.IsTrue(gmp_lib.mpz_get_si(root) == 21);
Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 739);

// Release unmanaged memory allocated for root, rem, and u.
gmp_lib.mpz_clears(root, rem, u, null);
' Create, initialize, and set the value of u to 10000.
Dim u As New mpz_t()
gmp_lib.mpz_init_set_si(u, 10000)

' Create, initialize, and set the values of root and rem to 0.
Dim root As New mpz_t()
Dim[rem] As New mpz_t()
gmp_lib.mpz_inits(root, [rem], Nothing)

' Set root = trunc(cbrt(10000)) and rem = u - root.
gmp_lib.mpz_rootrem(root, [rem], u, 3UI)

' Assert that root is 21, and rem is 739.
Assert.IsTrue(gmp_lib.mpz_get_si(root) = 21)
Assert.IsTrue(gmp_lib.mpz_get_si([rem]) = 739)

' Release unmanaged memory allocated for root, rem, and u.
gmp_lib.mpz_clears(root, [rem], u, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_power_p
mpz_perfect_square_p
mpz_root
mpz_sqrt
mpz_sqrtrem


gmp_lib.mpz_rrandomb Method

gmp_libmpz_rrandomb Method
Generate a random integer with long strings of zeros and ones in the binary representation.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_rrandomb(
    mpz_t rop,
    gmp_randstate_t state,
    mp_bitcnt_t n
)
Public Shared Sub mpz_rrandomb (
    rop As mpz_t,
    state As gmp_randstate_t,
    n As mp_bitcnt_t
)
public:
static void mpz_rrandomb(
    mpz_t^ rop,
    gmp_randstate_t^ state,
    mp_bitcnt_t n
)
static member mpz_rrandomb :
        rop : mpz_t *
        state : gmp_randstate_t *
        n : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
state
Type: Math.Gmp.Nativegmp_randstate_t
The random number generator state.
n
Type: Math.Gmp.Nativemp_bitcnt_t
The operand integer.
Remarks

Useful for testing functions and algorithms, since this kind of random numbers have proven to be more likely to trigger corner-case bugs. The random number will be in the range 2^(n - 1) to 2^n - 1, inclusive.

The variable state must be initialized by calling one of the gmp_randinit functions (GNU MP - Random State Initialization) before invoking this function.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 100000U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer in the range [2^(50-1), (2^50)-1].
gmp_lib.mpz_rrandomb(rop, state, 50);

// Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clear(rop);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Generate a random integer in the range [2^(50-1), (2^50)-1].
gmp_lib.mpz_rrandomb(rop, state, 50)

' Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_urandomb
mpz_urandomm
mpz_random
mpz_random2


gmp_lib.mpz_scan0 Method

gmp_libmpz_scan0 Method
Scan op for 0 bit.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpz_scan0(
    mpz_t op,
    mp_bitcnt_t starting_bit
)
Public Shared Function mpz_scan0 (
    op As mpz_t,
    starting_bit As mp_bitcnt_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_scan0(
    mpz_t^ op,
    mp_bitcnt_t starting_bit
)
static member mpz_scan0 :
        op : mpz_t *
        starting_bit : mp_bitcnt_t -> mp_bitcnt_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.
starting_bit
Type: Math.Gmp.Nativemp_bitcnt_t
The start bit index position.

Return Value

Type: mp_bitcnt_t
Return the index of the found bit.
Remarks

Scan op, starting from bit starting_bit, towards more significant bits, until the first 0 bit is found. Return the index of the found bit.

If the bit at starting_bit is already what’s sought, then starting_bit is returned.

If there’s no bit found, then the largest possible mp_bitcnt_t is returned. This will happen in mpz_scan0 past the end of a negative number, or mpz_scan1 past the end of a nonnegative number.

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 70.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 70U);

// Assert that the first 0 bit starting from bit 1 in op is bit 3.
Assert.IsTrue(gmp_lib.mpz_scan0(op, 1U) == 3U);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 70.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 70UI)

' Assert that the first 0 bit starting from bit 1 in op is bit 3.
Assert.IsTrue(gmp_lib.mpz_scan0(op, 1UI) = 3UI)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_scan1 Method

gmp_libmpz_scan1 Method
Scan op for 1 bit.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_bitcnt_t mpz_scan1(
    mpz_t op,
    mp_bitcnt_t starting_bit
)
Public Shared Function mpz_scan1 (
    op As mpz_t,
    starting_bit As mp_bitcnt_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_scan1(
    mpz_t^ op,
    mp_bitcnt_t starting_bit
)
static member mpz_scan1 :
        op : mpz_t *
        starting_bit : mp_bitcnt_t -> mp_bitcnt_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.
starting_bit
Type: Math.Gmp.Nativemp_bitcnt_t
The start bit index position.

Return Value

Type: mp_bitcnt_t
Return the index of the found bit.
Remarks

Scan op, starting from bit starting_bit, towards more significant bits, until the first 1 bit is found. Return the index of the found bit.

If the bit at starting_bit is already what’s sought, then starting_bit is returned.

If there’s no bit found, then the largest possible mp_bitcnt_t is returned. This will happen in mpz_scan0 past the end of a negative number, or mpz_scan1 past the end of a nonnegative number.

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 70.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 70U);

// Assert that the first 1 bit starting from bit 3 in op is bit 6.
Assert.IsTrue(gmp_lib.mpz_scan1(op, 3U) == 6U);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 70.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 70UI)

' Assert that the first 1 bit starting from bit 3 in op is bit 6.
Assert.IsTrue(gmp_lib.mpz_scan1(op, 3UI) = 6UI)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_set Method

gmp_libmpz_set Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_set (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_set(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_set :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: Math.Gmp.Nativempz_t
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new integer x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);
gmp_lib.mpz_set_si(x, 10);

// Create, initialize, and set a new integer y to -210.
mpz_t y = new mpz_t();
gmp_lib.mpz_init(y);
gmp_lib.mpz_set_si(y, -210);

// Assign the value of y to x.
gmp_lib.mpz_set(x, y);

// Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, null);
' Create, initialize, and set a new integer x to 10.
Dim x As New mpz_t()

gmp_lib.mpz_init(x)
gmp_lib.mpz_set_si(x, 10)

' Create, initialize, and set a new integer y to -210.
Dim y As New mpz_t()
gmp_lib.mpz_init(y)
gmp_lib.mpz_set_si(y, -210)

' Assign the value of y to x.
gmp_lib.mpz_set(x, y)

' Assert that the value of x is -210.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set_ui
mpz_set_si
mpz_set_d
mpz_set_q
mpz_set_f
mpz_set_str
mpz_swap


gmp_lib.mpz_set_d Method

gmp_libmpz_set_d Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set_d(
    mpz_t rop,
    double op
)
Public Shared Sub mpz_set_d (
    rop As mpz_t,
    op As Double
)
public:
static void mpz_set_d(
    mpz_t^ rop,
    double op
)
static member mpz_set_d :
        rop : mpz_t *
        op : float -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemDouble
The source integer.
Remarks

mpz_set_d truncate op to make it an integer.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x to the truncation of 10.7.
gmp_lib.mpz_set_d(x, 10.7D);

// Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create and initialize a new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x to the truncation of 10.7.
gmp_lib.mpz_set_d(x, 10.7)

' Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_si
mpz_set_q
mpz_set_f
mpz_set_str
mpz_swap


gmp_lib.mpz_set_f Method

gmp_libmpz_set_f Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set_f(
    mpz_t rop,
    mpf_t op
)
Public Shared Sub mpz_set_f (
    rop As mpz_t,
    op As mpf_t
)
public:
static void mpz_set_f(
    mpz_t^ rop,
    mpf_t^ op
)
static member mpz_set_f :
        rop : mpz_t *
        op : mpf_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: Math.Gmp.Nativempf_t
The source integer.
Remarks

mpz_set_f truncate op to make it an integer.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x, and float y.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);
mpf_t y = "1.7007e3";

// Set the value of x to the truncation of 1700.7.
gmp_lib.mpz_set_f(x, y);

// Assert that the value of x is 1700.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 1700);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clear(x);
gmp_lib.mpf_clear(y);
' Create and initialize new integer x, and float y.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)
Dim y As mpf_t = "1.7007e3"

' Set the value of x to the truncation of 1700.7.
gmp_lib.mpz_set_f(x, y)

' Assert that the value of x is 1700.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 1700)

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

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_si
mpz_set_d
mpz_set_q
mpz_set_str
mpz_swap


gmp_lib.mpz_set_q Method

gmp_libmpz_set_q Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set_q(
    mpz_t rop,
    mpq_t op
)
Public Shared Sub mpz_set_q (
    rop As mpz_t,
    op As mpq_t
)
public:
static void mpz_set_q(
    mpz_t^ rop,
    mpq_t^ op
)
static member mpz_set_q :
        rop : mpz_t *
        op : mpq_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: Math.Gmp.Nativempq_t
The source integer.
Remarks

mpz_set_q truncate op to make it an integer.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x, and rational y.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);
mpq_t y = "100/3";

// Set the value of x to the truncation of 100/3.
gmp_lib.mpz_set_q(x, y);

// Assert that the value of x is 33.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 33);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clear(x);
gmp_lib.mpq_clear(y);
' Create and initialize new integer x, and rational y.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)
Dim y As mpq_t = "100/3"

' Set the value of x to the truncation of 100/3.
gmp_lib.mpz_set_q(x, y)

' Assert that the value of x is 33.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 33)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clear(x)
gmp_lib.mpq_clear(y)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_si
mpz_set_d
mpz_set_f
mpz_set_str
mpz_swap


gmp_lib.mpz_set_si Method

gmp_libmpz_set_si Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set_si(
    mpz_t rop,
    int op
)
Public Shared Sub mpz_set_si (
    rop As mpz_t,
    op As Integer
)
public:
static void mpz_set_si(
    mpz_t^ rop,
    int op
)
static member mpz_set_si :
        rop : mpz_t *
        op : int -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemInt32
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x to -10.
gmp_lib.mpz_set_si(x, -10);

// Assert that the value of x is -10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create and initialize a new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x to -10.
gmp_lib.mpz_set_si(x, -10)

' Assert that the value of x is -10.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -10)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_d
mpz_set_q
mpz_set_f
mpz_set_str
mpz_swap


gmp_lib.mpz_set_str Method

gmp_libmpz_set_str Method
Set the value of rop from str, a null-terminated C string in base base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_set_str(
    mpz_t rop,
    char_ptr str,
    int base
)
Public Shared Function mpz_set_str (
    rop As mpz_t,
    str As char_ptr,
    base As Integer
) As Integer
public:
static int mpz_set_str(
    mpz_t^ rop,
    char_ptr str,
    int base
)
static member mpz_set_str :
        rop : mpz_t *
        str : char_ptr *
        base : int -> int

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
str
Type: Math.Gmp.Nativechar_ptr
The source integer.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
This function returns 0 if the entire string is a valid number in base base. Otherwise it returns −1.
Remarks

White space is allowed in the string, and is simply ignored.

The base may vary from 2 to 62, or if base is 0, then the leading characters are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or decimal otherwise.

For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter represent 36..61.

Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x.
char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321");
gmp_lib.mpz_set_str(x, value, 10);

// Assert the value of x.
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", ""));

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
' Create and initialize a new integer x.
Dim x As New mpz_t()
gmp_lib.mpz_init(x)

' Set the value of x.
Dim value As New char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321")
gmp_lib.mpz_set_str(x, value, 10)

' Assert the value of x.
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x)
Assert.IsTrue(s.ToString() = value.ToString().Replace(" ", ""))

' Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
gmp_lib.free(s)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_si
mpz_set_d
mpz_set_q
mpz_set_f
mpz_swap


gmp_lib.mpz_set_ui Method

gmp_libmpz_set_ui Method
Set the value of rop from op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_set_ui(
    mpz_t rop,
    uint op
)
Public Shared Sub mpz_set_ui (
    rop As mpz_t,
    op As UInteger
)
public:
static void mpz_set_ui(
    mpz_t^ rop,
    unsigned int op
)
static member mpz_set_ui :
        rop : mpz_t *
        op : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
op
Type: SystemUInt32
The source integer.
Examples
C#
VB
C++
F#
Copy
// Create and initialize a new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x to 10.
gmp_lib.mpz_set_ui(x, 10U);

// Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);

// Release unmanaged memory allocated for x.
gmp_lib.mpz_clear(x);
' Create and initialize a new integer x.
Dim x As New mpz_t()

gmp_lib.mpz_init(x)

' Set the value of x to 10.
gmp_lib.mpz_set_ui(x, 10UI)

' Assert that the value of x is 10.
Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI)

' Release unmanaged memory allocated for x.
gmp_lib.mpz_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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_si
mpz_set_d
mpz_set_q
mpz_set_f
mpz_set_str
mpz_swap


gmp_lib.mpz_setbit Method

gmp_libmpz_setbit Method
Set bit bit_index in rop.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_setbit(
    mpz_t rop,
    mp_bitcnt_t bit_index
)
Public Shared Sub mpz_setbit (
    rop As mpz_t,
    bit_index As mp_bitcnt_t
)
public:
static void mpz_setbit(
    mpz_t^ rop,
    mp_bitcnt_t bit_index
)
static member mpz_setbit :
        rop : mpz_t *
        bit_index : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
bit_index
Type: Math.Gmp.Nativemp_bitcnt_t
The index of the bit to set.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 70.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init_set_si(rop, 70);

// Set bit 3 of rop.
gmp_lib.mpz_setbit(rop, 3U);

// Assert that rop is 78.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 70.
Dim rop As New mpz_t()
gmp_lib.mpz_init_set_si(rop, 70)

' Set bit 3 of rop.
gmp_lib.mpz_setbit(rop, 3UI)

' Assert that rop is 78.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 78)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.mpz_sgn Method

gmp_libmpz_sgn Method
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_sgn(
    mpz_t op
)
Public Shared Function mpz_sgn (
    op As mpz_t
) As Integer
public:
static int mpz_sgn(
    mpz_t^ op
)
static member mpz_sgn :
        op : mpz_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: Int32
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to -10.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, -10);

// Assert that the sign of op is -1.
Assert.IsTrue(gmp_lib.mpz_sgn(op) == -1);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to -10.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, -10)

' Assert that the sign of op is -1.
Assert.IsTrue(gmp_lib.mpz_sgn(op) = -1)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cmp
mpz_cmp_d
mpz_cmp_si
mpz_cmp_ui
mpz_cmpabs
mpz_cmpabs_d
mpz_cmpabs_ui


gmp_lib.mpz_si_kronecker Method

gmp_libmpz_si_kronecker Method
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_si_kronecker(
    int a,
    mpz_t b
)
Public Shared Function mpz_si_kronecker (
    a As Integer,
    b As mpz_t
) As Integer
public:
static int mpz_si_kronecker(
    int a,
    mpz_t^ b
)
static member mpz_si_kronecker :
        a : int *
        b : mpz_t -> int

Parameters

a
Type: SystemInt32
The first operand integer.
b
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Remarks

When b is odd the Jacobi symbol and Kronecker symbol are identical, so mpz_kronecker_ui, etc. can be used for mixed precision Jacobi symbols too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of b to 4.
mpz_t b = new mpz_t();
gmp_lib.mpz_init_set_ui(b, 4U);

// Assert that the Kronecker symbol of (15/b) is 1.
Assert.IsTrue(gmp_lib.mpz_si_kronecker(15, b) == 1);

// Release unmanaged memory allocated for b.
gmp_lib.mpz_clear(b);
' Create, initialize, and set the value of b to 4.
Dim b As New mpz_t()
gmp_lib.mpz_init_set_ui(b, 4UI)

' Assert that the Kronecker symbol of (15/b) is 1.
Assert.IsTrue(gmp_lib.mpz_si_kronecker(15, b) = 1)

' Release unmanaged memory allocated for b.
gmp_lib.mpz_clear(b)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_kronecker
mpz_kronecker_si
mpz_kronecker_ui
mpz_legendre
mpz_ui_kronecker


gmp_lib.mpz_size Method

gmp_libmpz_size Method
Return the size of op measured in number of limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static mp_size_t mpz_size(
    mpz_t op
)
Public Shared Function mpz_size (
    op As mpz_t
) As mp_size_t
public:
static mp_size_t mpz_size(
    mpz_t^ op
)
static member mpz_size :
        op : mpz_t -> mp_size_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.

Return Value

Type: mp_size_t
The size of op measured in number of limbs.
Remarks

If op is zero, the returned value will be zero.

Examples
C#
VB
C++
F#
Copy
// Create and initialize new integer x.
mpz_t op = new mpz_t();
char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD");
gmp_lib.mpz_init_set_str(op, value, 16);

// Assert the value of the limbs of op.
if (gmp_lib.mp_bytes_per_limb == 4)
    Assert.IsTrue(gmp_lib.mpz_size(op) == 3);
else // gmp_lib.mp_bytes_per_limb == 8
    Assert.IsTrue(gmp_lib.mpz_size(op) == 2);

// Release unmanaged memory allocated for op and value.
gmp_lib.mpz_clear(op);
gmp_lib.free(value);
' Create and initialize new integer x.
Dim op As New mpz_t()
Dim value As New char_ptr("1000 ABCD 1234 7AB8 24FD")
gmp_lib.mpz_init_set_str(op, value, 16)

' Assert the value of the limbs of op.
If gmp_lib.mp_bytes_per_limb = 4 Then
    Assert.IsTrue(gmp_lib.mpz_size(op) = 3)
Else ' gmp_lib.mp_bytes_per_limb == 8
    Assert.IsTrue(gmp_lib.mpz_size(op) = 2)
End If

' Release unmanaged memory allocated for op and value.
gmp_lib.mpz_clear(op)
gmp_lib.free(value)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
_mpz_realloc
mpz_getlimbn
mpz_limbs_read
mpz_limbs_write
mpz_limbs_modify
mpz_limbs_finish
mpz_roinit_n


gmp_lib.mpz_sizeinbase Method

gmp_libmpz_sizeinbase Method
Return the size of op measured in number of digits in the given base.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static size_t mpz_sizeinbase(
    mpz_t op,
    int base
)
Public Shared Function mpz_sizeinbase (
    op As mpz_t,
    base As Integer
) As size_t
public:
static size_t mpz_sizeinbase(
    mpz_t^ op,
    int base
)
static member mpz_sizeinbase :
        op : mpz_t *
        base : int -> size_t

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer
base
Type: SystemInt32
The base.

Return Value

Type: size_t
The size of op measured in number of digits in the given base.
Remarks

base can vary from 2 to 62. The sign of op is ignored, just the absolute value is used. The result will be either exact or 1 too big. If base is a power of 2, the result is always exact. If op is zero the return value is always 1.

This function can be used to determine the space required when converting op to a string. The right amount of allocation is normally two more than the value returned by mpz_sizeinbase, one extra for a minus sign and one for the null-terminator.

It will be noted that mpz_sizeinbase(op, 2) can be used to locate the most significant 1 bit in op, counting from 1. (Unlike the bitwise functions which start from 0, see GNU MP - Logical and Bit Manipulation Functions.)

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Assert size in different bases.
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) == 14);
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) == 5);
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) == 5);
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) == 4);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Assert size in different bases.
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) = 14)
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) = 5)
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) = 5)
Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) = 4)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_fits_ulong_p
mpz_fits_slong_p
mpz_fits_uint_p
mpz_fits_sint_p
mpz_fits_ushort_p
mpz_fits_sshort_p
mpz_odd_p
mpz_even_p


gmp_lib.mpz_sqrt Method

gmp_libmpz_sqrt Method
Set rop to the truncated integer part of the square root of op.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_sqrt(
    mpz_t rop,
    mpz_t op
)
Public Shared Sub mpz_sqrt (
    rop As mpz_t,
    op As mpz_t
)
public:
static void mpz_sqrt(
    mpz_t^ rop,
    mpz_t^ op
)
static member mpz_sqrt :
        rop : mpz_t *
        op : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result square root integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = trunc(sqrt(op)).
gmp_lib.mpz_sqrt(rop, op);

// Assert that rop is 100.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 100);

// Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of op to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = trunc(sqrt(op)).
gmp_lib.mpz_sqrt(rop, op)

' Assert that rop is 100.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 100)

' Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_power_p
mpz_perfect_square_p
mpz_root
mpz_rootrem
mpz_sqrtrem


gmp_lib.mpz_sqrtrem Method

gmp_libmpz_sqrtrem Method
Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_sqrtrem(
    mpz_t rop1,
    mpz_t rop2,
    mpz_t op
)
Public Shared Sub mpz_sqrtrem (
    rop1 As mpz_t,
    rop2 As mpz_t,
    op As mpz_t
)
public:
static void mpz_sqrtrem(
    mpz_t^ rop1,
    mpz_t^ rop2,
    mpz_t^ op
)
static member mpz_sqrtrem :
        rop1 : mpz_t *
        rop2 : mpz_t *
        op : mpz_t -> unit

Parameters

rop1
Type: Math.Gmp.Nativempz_t
The result square root integer.
rop2
Type: Math.Gmp.Nativempz_t
The result remainder integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 10000);

// Create, initialize, and set the values of root and rem to 0.
mpz_t root = new mpz_t();
mpz_t rem = new mpz_t();
gmp_lib.mpz_inits(root, rem);

// Set root = trunc(sqrt(op)), and rem = op - root.
gmp_lib.mpz_sqrtrem(root, rem, op);

// Assert that root is 100, and rem is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(root) == 100);
Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 0);

// Release unmanaged memory allocated for root, rem, and op.
gmp_lib.mpz_clears(root, rem, op, null);
' Create, initialize, and set the value of op to 10000.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_si(op, 10000)

' Create, initialize, and set the values of root and rem to 0.
Dim root As New mpz_t()
Dim[rem] As New mpz_t()
gmp_lib.mpz_inits(root, [rem])

' Set root = trunc(sqrt(op)), and rem = op - root.
gmp_lib.mpz_sqrtrem(root, [rem], op)

' Assert that root is 100, and rem is 0.
Assert.IsTrue(gmp_lib.mpz_get_si(root) = 100)
Assert.IsTrue(gmp_lib.mpz_get_si([rem]) = 0)

' Release unmanaged memory allocated for root, rem, and op.
gmp_lib.mpz_clears(root, [rem], op, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_perfect_power_p
mpz_perfect_square_p
mpz_root
mpz_rootrem
mpz_sqrt


gmp_lib.mpz_sub Method

gmp_libmpz_sub Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_sub(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_sub (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_sub(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_sub :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 12222.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 12222U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x - y.
gmp_lib.mpz_sub(z, x, y);

// Assert that z = x - y.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 12222.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 12222UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x - y.
gmp_lib.mpz_sub(z, x, y)

' Assert that z = x - y.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = -2222)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub_ui
mpz_submul
mpz_ui_sub


gmp_lib.mpz_sub_ui Method

gmp_libmpz_sub_ui Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_sub_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_sub_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_sub_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_sub_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = x - 12222.
gmp_lib.mpz_sub_ui(z, x, 12222U);

// Assert that z = x - 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = x - 12222.
gmp_lib.mpz_sub_ui(z, x, 12222UI)

' Assert that z = x - 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = -2222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul
mpz_ui_sub


gmp_lib.mpz_submul Method

gmp_libmpz_submul Method
Set rop to rop - op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_submul(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_submul (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_submul(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_submul :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of y to 12222.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 12222U);

// Create, initialize, and set the value of z to 20000.
mpz_t z = new mpz_t();
gmp_lib.mpz_init_set_si(z, 20000);

// Set z -= x * y.
gmp_lib.mpz_submul(z, x, y);

// Assert that z has been decremented by 10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - 10000 * 12222);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of y to 12222.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 12222UI)

' Create, initialize, and set the value of z to 20000.
Dim z As New mpz_t()
gmp_lib.mpz_init_set_si(z, 20000)

' Set z -= x * y.
gmp_lib.mpz_submul(z, x, y)

' Assert that z has been decremented by 10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 - 10000 * 12222)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul_ui


gmp_lib.mpz_submul_ui Method

gmp_libmpz_submul_ui Method
Set rop to rop - op1 * op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_submul_ui(
    mpz_t rop,
    mpz_t op1,
    uint op2
)
Public Shared Sub mpz_submul_ui (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As UInteger
)
public:
static void mpz_submul_ui(
    mpz_t^ rop,
    mpz_t^ op1,
    unsigned int op2
)
static member mpz_submul_ui :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: SystemUInt32
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to -10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, -10000);

// Create, initialize, and set the value of z to 20000.
mpz_t z = new mpz_t();
gmp_lib.mpz_init_set_si(z, 20000);

// Set z -= x * 12222U.
gmp_lib.mpz_submul_ui(z, x, 12222U);

// Assert that z has been decremented by -10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - -10000 * 12222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to -10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, -10000)

' Create, initialize, and set the value of z to 20000.
Dim z As New mpz_t()
gmp_lib.mpz_init_set_si(z, 20000)

' Set z -= x * 12222U.
gmp_lib.mpz_submul_ui(z, x, 12222UI)

' Assert that z has been decremented by -10000 * 12222.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 - -10000 * 12222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_submul


gmp_lib.mpz_swap Method

gmp_libmpz_swap Method
Swap the values rop1 and rop2 efficiently.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_swap(
    mpz_t rop1,
    mpz_t rop2
)
Public Shared Sub mpz_swap (
    rop1 As mpz_t,
    rop2 As mpz_t
)
public:
static void mpz_swap(
    mpz_t^ rop1,
    mpz_t^ rop2
)
static member mpz_swap :
        rop1 : mpz_t *
        rop2 : mpz_t -> unit

Parameters

rop1
Type: Math.Gmp.Nativempz_t
The first integer.
rop2
Type: Math.Gmp.Nativempz_t
The second integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set a new integer x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, 10);

// Create, initialize, and set a new integer x to -210.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_si(y, -210);

// Swap the values of x and y.
gmp_lib.mpz_swap(x, y);

// Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);
Assert.IsTrue(gmp_lib.mpz_get_si(y) == 10);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, null);
' Create, initialize, and set a new integer x to 10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, 10)

' Create, initialize, and set a new integer x to -210.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_si(y, -210)

' Swap the values of x and y.
gmp_lib.mpz_swap(x, y)

' Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210)
Assert.IsTrue(gmp_lib.mpz_get_si(y) = 10)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_set
mpz_set_ui
mpz_set_si
mpz_set_d
mpz_set_q
mpz_set_f
mpz_set_str


gmp_lib.mpz_tdiv_q Method

gmp_libmpz_tdiv_q Method
Set the quotient q to trunc(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_tdiv_q(
    mpz_t q,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_tdiv_q (
    q As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_tdiv_q(
    mpz_t^ q,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_tdiv_q :
        q : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = trunc(n / d).
gmp_lib.mpz_tdiv_q(q, n, d);

// Assert that q is trunc(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);

// Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = trunc(n / d).
gmp_lib.mpz_tdiv_q(q, n, d)

' Assert that q is trunc(10000 / 3).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)

' Release unmanaged memory allocated for n, d, and q.
gmp_lib.mpz_clears(n, d, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_q_2exp Method

gmp_libmpz_tdiv_q_2exp Method
Set the quotient q to trunc(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_tdiv_q_2exp(
    mpz_t q,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_tdiv_q_2exp (
    q As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_tdiv_q_2exp(
    mpz_t^ q,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_tdiv_q_2exp :
        q : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = trunc(n / 2^2).
gmp_lib.mpz_tdiv_q_2exp(q, n, 2U);

// Assert that q is trunc(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = trunc(n / 2^2).
gmp_lib.mpz_tdiv_q_2exp(q, n, 2UI)

' Assert that q is trunc(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2500)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_q_ui Method

gmp_libmpz_tdiv_q_ui Method
Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static ulong mpz_tdiv_q_ui(
    mpz_t q,
    mpz_t n,
    uint d
)
Public Shared Function mpz_tdiv_q_ui (
    q As mpz_t,
    n As mpz_t,
    d As UInteger
) As ULong
public:
static unsigned long long mpz_tdiv_q_ui(
    mpz_t^ q,
    mpz_t^ n,
    unsigned int d
)
static member mpz_tdiv_q_ui :
        q : mpz_t *
        n : mpz_t *
        d : uint32 -> uint64

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt64
Return the remainder r = | n - q * d |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = trunc(n / 3) and return r = n - 3 * q.
// Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3U) == 1U);
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = trunc(n / 3) and return r = n - 3 * q.
' Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3UI) = 1UI)
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_qr Method

gmp_libmpz_tdiv_qr Method
Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_tdiv_qr(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_tdiv_qr (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_tdiv_qr(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_tdiv_qr :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = trunc(n / 3) and r = n - d * q.
gmp_lib.mpz_tdiv_qr(q, r, n, d);

// Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

' Set q = trunc(n / 3) and r = n - d * q.
gmp_lib.mpz_tdiv_qr(q, r, n, d)

' Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, d, q, and r.
gmp_lib.mpz_clears(n, d, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_qr_ui Method

gmp_libmpz_tdiv_qr_ui Method
Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_tdiv_qr_ui(
    mpz_t q,
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_tdiv_qr_ui (
    q As mpz_t,
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_tdiv_qr_ui(
    mpz_t^ q,
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_tdiv_qr_ui :
        q : mpz_t *
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the values of q and r to 0.
mpz_t q = new mpz_t();
mpz_t r = new mpz_t();
gmp_lib.mpz_inits(q, r, null);

// Set q = trunc(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_tdiv_qr_ui(q, r, n, 3U) == 1U);

// Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the values of q and r to 0.
Dim q As New mpz_t()
Dim r As New mpz_t()
gmp_lib.mpz_inits(q, r, Nothing)

' Set q = trunc(n / 3), r = n - d * q, and return r.
Assert.IsTrue(gmp_lib.mpz_tdiv_qr_ui(q, r, n, 3UI) = 1UI)

' Assert that q is 3333, and that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, q, and r.
gmp_lib.mpz_clears(n, q, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_r Method

gmp_libmpz_tdiv_r Method
Set the remainder r to n - q * d where q = trunc(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_tdiv_r(
    mpz_t r,
    mpz_t n,
    mpz_t d
)
Public Shared Sub mpz_tdiv_r (
    r As mpz_t,
    n As mpz_t,
    d As mpz_t
)
public:
static void mpz_tdiv_r(
    mpz_t^ r,
    mpz_t^ n,
    mpz_t^ d
)
static member mpz_tdiv_r :
        r : mpz_t *
        n : mpz_t *
        d : mpz_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - d * trunc(n / d).
gmp_lib.mpz_tdiv_r(r, n, d);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of d to 3.
Dim d As New mpz_t()
gmp_lib.mpz_init_set_si(d, 3)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - d * trunc(n / d).
gmp_lib.mpz_tdiv_r(r, n, d)

' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n, d, and r.
gmp_lib.mpz_clears(n, d, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_r_2exp Method

gmp_libmpz_tdiv_r_2exp Method
Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_tdiv_r_2exp(
    mpz_t r,
    mpz_t n,
    mp_bitcnt_t b
)
Public Shared Sub mpz_tdiv_r_2exp (
    r As mpz_t,
    n As mpz_t,
    b As mp_bitcnt_t
)
public:
static void mpz_tdiv_r_2exp(
    mpz_t^ r,
    mpz_t^ n,
    mp_bitcnt_t b
)
static member mpz_tdiv_r_2exp :
        r : mpz_t *
        n : mpz_t *
        b : mp_bitcnt_t -> unit

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 2^2 * trunc(n / 2^2)
gmp_lib.mpz_tdiv_r_2exp(r, n, 2U);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10001.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10001)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - 2^2 * trunc(n / 2^2)
gmp_lib.mpz_tdiv_r_2exp(r, n, 2UI)

' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp


gmp_lib.mpz_tdiv_r_ui Method

gmp_libmpz_tdiv_r_ui Method
Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_tdiv_r_ui(
    mpz_t r,
    mpz_t n,
    uint d
)
Public Shared Function mpz_tdiv_r_ui (
    r As mpz_t,
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_tdiv_r_ui(
    mpz_t^ r,
    mpz_t^ n,
    unsigned int d
)
static member mpz_tdiv_r_ui :
        r : mpz_t *
        n : mpz_t *
        d : uint32 -> uint32

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
Return | r |.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of r to 0.
mpz_t r = new mpz_t();
gmp_lib.mpz_init(r);

// Set r = n - 3 * trunc(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_tdiv_r_ui(r, n, 3U) == 1U);

// Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);

// Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of r to 0.
Dim r As New mpz_t()
gmp_lib.mpz_init(r)

' Set r = n - 3 * trunc(n / 3), and return |r|.
Assert.IsTrue(gmp_lib.mpz_tdiv_r_ui(r, n, 3UI) = 1UI)

' Assert that r is 1.
Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1)

' Release unmanaged memory allocated for n and r.
gmp_lib.mpz_clears(n, r, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_qr_ui
mpz_tdiv_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tdiv_ui Method

gmp_libmpz_tdiv_ui Method
Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static uint mpz_tdiv_ui(
    mpz_t n,
    uint d
)
Public Shared Function mpz_tdiv_ui (
    n As mpz_t,
    d As UInteger
) As UInteger
public:
static unsigned int mpz_tdiv_ui(
    mpz_t^ n,
    unsigned int d
)
static member mpz_tdiv_ui :
        n : mpz_t *
        d : uint32 -> uint32

Parameters

n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: UInt32
The remainder | r | where r = n - q * d, and where q = trunc(n / d).
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Assert that returned value is |n - 3 * trunc(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_tdiv_ui(n, 3U) == 1U);

// Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Assert that returned value is |n - 3 * trunc(n / 3)|.
Assert.IsTrue(gmp_lib.mpz_tdiv_ui(n, 3UI) = 1UI)

' Release unmanaged memory allocated for n.
gmp_lib.mpz_clear(n)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_cdiv_qr
mpz_congruent_p
mpz_divexact
mpz_divisible_p
mpz_fdiv_qr
mpz_mod
mpz_tdiv_q
mpz_tdiv_r
mpz_tdiv_qr
mpz_tdiv_q_ui
mpz_tdiv_r_ui
mpz_tdiv_qr_ui
mpz_tdiv_q_2exp
mpz_tdiv_r_2exp


gmp_lib.mpz_tstbit Method

gmp_libmpz_tstbit Method
Test bit bit_index in op and return 0 or 1 accordingly.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_tstbit(
    mpz_t op,
    mp_bitcnt_t bit_index
)
Public Shared Function mpz_tstbit (
    op As mpz_t,
    bit_index As mp_bitcnt_t
) As Integer
public:
static int mpz_tstbit(
    mpz_t^ op,
    mp_bitcnt_t bit_index
)
static member mpz_tstbit :
        op : mpz_t *
        bit_index : mp_bitcnt_t -> int

Parameters

op
Type: Math.Gmp.Nativempz_t
bit_index
Type: Math.Gmp.Nativemp_bitcnt_t

Return Value

Type: Int32
Test bit bit_index in op and return 0 or 1 accordingly.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 70.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init_set_si(rop, 70);

// Assert that bit 3 of rop is 0.
Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3U) == 0);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 70.
Dim rop As New mpz_t()
gmp_lib.mpz_init_set_si(rop, 70)

' Assert that bit 3 of rop is 0.
Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3UI) = 0)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_xor
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit


gmp_lib.mpz_ui_kronecker Method

gmp_libmpz_ui_kronecker Method
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static int mpz_ui_kronecker(
    uint a,
    mpz_t b
)
Public Shared Function mpz_ui_kronecker (
    a As UInteger,
    b As mpz_t
) As Integer
public:
static int mpz_ui_kronecker(
    unsigned int a,
    mpz_t^ b
)
static member mpz_ui_kronecker :
        a : uint32 *
        b : mpz_t -> int

Parameters

a
Type: SystemUInt32
The first operand integer.
b
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Remarks

When b is odd the Jacobi symbol and Kronecker symbol are identical, so mpz_kronecker_ui, etc. can be used for mixed precision Jacobi symbols too.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of b to 4.
mpz_t b = new mpz_t();
gmp_lib.mpz_init_set_ui(b, 4U);

// Assert that the Kronecker symbol of (15/b) is 1.
Assert.IsTrue(gmp_lib.mpz_ui_kronecker(15U, b) == 1);

// Release unmanaged memory allocated for b.
gmp_lib.mpz_clear(b);
' Create, initialize, and set the value of b to 4.
Dim b As New mpz_t()
gmp_lib.mpz_init_set_ui(b, 4UI)

' Assert that the Kronecker symbol of (15/b) is 1.
Assert.IsTrue(gmp_lib.mpz_ui_kronecker(15UI, b) = 1)

' Release unmanaged memory allocated for b.
gmp_lib.mpz_clear(b)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_kronecker
mpz_kronecker_si
mpz_kronecker_ui
mpz_legendre
mpz_si_kronecker


gmp_lib.mpz_ui_pow_ui Method

gmp_libmpz_ui_pow_ui Method
Set rop to base^exp. The case 0^0 yields 1.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_ui_pow_ui(
    mpz_t rop,
    uint base,
    uint exp
)
Public Shared Sub mpz_ui_pow_ui (
    rop As mpz_t,
    base As UInteger,
    exp As UInteger
)
public:
static void mpz_ui_pow_ui(
    mpz_t^ rop,
    unsigned int base,
    unsigned int exp
)
static member mpz_ui_pow_ui :
        rop : mpz_t *
        base : uint32 *
        exp : uint32 -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
base
Type: SystemUInt32
The base integer.
exp
Type: SystemUInt32
The exponent integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop = 2^4.
gmp_lib.mpz_ui_pow_ui(rop, 2U, 4U);

// Assert that rop is 16.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16);

// Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop = 2^4.
gmp_lib.mpz_ui_pow_ui(rop, 2UI, 4UI)

' Assert that rop is 16.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 16)

' Release unmanaged memory allocated for rop.
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_powm
mpz_powm_ui
mpz_powm_sec
mpz_pow_ui


gmp_lib.mpz_ui_sub Method

gmp_libmpz_ui_sub Method
Set rop to op1 - op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_ui_sub(
    mpz_t rop,
    uint op1,
    mpz_t op2
)
Public Shared Sub mpz_ui_sub (
    rop As mpz_t,
    op1 As UInteger,
    op2 As mpz_t
)
public:
static void mpz_ui_sub(
    mpz_t^ rop,
    unsigned int op1,
    mpz_t^ op2
)
static member mpz_ui_sub :
        rop : mpz_t *
        op1 : uint32 *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: SystemUInt32
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of x to 10000.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 10000U);

// Create, initialize, and set the value of z to 0.
mpz_t z = new mpz_t();
gmp_lib.mpz_init(z);

// Set z = 12222 - x.
gmp_lib.mpz_ui_sub(z, 12222U, x);

// Assert that z = 12222 - x.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2222);

// Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, null);
' Create, initialize, and set the value of x to 10000.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 10000UI)

' Create, initialize, and set the value of z to 0.
Dim z As New mpz_t()
gmp_lib.mpz_init(z)

' Set z = 12222 - x.
gmp_lib.mpz_ui_sub(z, 12222UI, x)

' Assert that z = 12222 - x.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2222)

' Release unmanaged memory allocated for x and z.
gmp_lib.mpz_clears(x, z, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_abs
mpz_add
mpz_addmul
mpz_mul
mpz_neg
mpz_sub
mpz_sub_ui
mpz_submul


gmp_lib.mpz_urandomb Method

gmp_libmpz_urandomb Method
Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_urandomb(
    mpz_t rop,
    gmp_randstate_t state,
    mp_bitcnt_t n
)
Public Shared Sub mpz_urandomb (
    rop As mpz_t,
    state As gmp_randstate_t,
    n As mp_bitcnt_t
)
public:
static void mpz_urandomb(
    mpz_t^ rop,
    gmp_randstate_t^ state,
    mp_bitcnt_t n
)
static member mpz_urandomb :
        rop : mpz_t *
        state : gmp_randstate_t *
        n : mp_bitcnt_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
state
Type: Math.Gmp.Nativegmp_randstate_t
The random number generator state.
n
Type: Math.Gmp.Nativemp_bitcnt_t
The operand integer.
Remarks

The variable state must be initialized by calling one of the gmp_randinit functions (GNU MP - Random State Initialization) before invoking this function.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 100000U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer in the range [0, (2^50)-1].
gmp_lib.mpz_urandomb(rop, state, 50);

// Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clear(rop);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Generate a random integer in the range [0, (2^50)-1].
gmp_lib.mpz_urandomb(rop, state, 50)

' Free all memory occupied by state and rop.
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clear(rop)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_urandomm
mpz_rrandomb
mpz_random
mpz_random2


gmp_lib.mpz_urandomm Method

gmp_libmpz_urandomm Method
Generate a uniform random integer in the range 0 to n - 1, inclusive.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_urandomm(
    mpz_t rop,
    gmp_randstate_t state,
    mpz_t n
)
Public Shared Sub mpz_urandomm (
    rop As mpz_t,
    state As gmp_randstate_t,
    n As mpz_t
)
public:
static void mpz_urandomm(
    mpz_t^ rop,
    gmp_randstate_t^ state,
    mpz_t^ n
)
static member mpz_urandomm :
        rop : mpz_t *
        state : gmp_randstate_t *
        n : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
state
Type: Math.Gmp.Nativegmp_randstate_t
The random number generator state.
n
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks

The variable state must be initialized by calling one of the gmp_randinit functions (GNU MP - Random State Initialization) before invoking this function.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 100000U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Create, initialize, and set a large integer.
mpz_t n = new mpz_t();
char_ptr value = new char_ptr("123 456 789 012 345 678 901");
gmp_lib.mpz_init_set_str(n, value, 10);

// Generate a random integer in the range [0, n-1].
gmp_lib.mpz_urandomm(rop, state, n);

// Free all memory occupied by state, rop, and n.
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clears(rop, n, null);
' Create, initialize, and seed a new random number generator.
Dim state As New gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
gmp_lib.gmp_randseed_ui(state, 100000UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Create, initialize, and set a large integer.
Dim n As New mpz_t()
Dim value As New char_ptr("123 456 789 012 345 678 901")
gmp_lib.mpz_init_set_str(n, value, 10)

' Generate a random integer in the range [0, n-1].
gmp_lib.mpz_urandomm(rop, state, n)

' Free all memory occupied by state, rop, and n.
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clears(rop, n, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_urandomb
mpz_rrandomb
mpz_random
mpz_random2


gmp_lib.mpz_xor Method

gmp_libmpz_xor Method
Set rop to op1 bitwise exclusive-or op2.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void mpz_xor(
    mpz_t rop,
    mpz_t op1,
    mpz_t op2
)
Public Shared Sub mpz_xor (
    rop As mpz_t,
    op1 As mpz_t,
    op2 As mpz_t
)
public:
static void mpz_xor(
    mpz_t^ rop,
    mpz_t^ op1,
    mpz_t^ op2
)
static member mpz_xor :
        rop : mpz_t *
        op1 : mpz_t *
        op2 : mpz_t -> unit

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

Examples
C#
VB
C++
F#
Copy
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the bitwise exclusive or of op1 and op2.
gmp_lib.mpz_xor(rop, op1, op2);

// Assert that rop is 121.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 121);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the bitwise exclusive or of op1 and op2.
gmp_lib.mpz_xor(rop, op1, op2)

' Assert that rop is 121.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 121)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mpz_and
mpz_ior
mpz_com
mpz_popcount
mpz_hamdist
mpz_scan0
mpz_scan1
mpz_setbit
mpz_clrbit
mpz_combit
mpz_tstbit


gmp_lib.reallocate Method

gmp_libreallocate Method
Resize a previously allocated block ptr of old_size bytes to be new_size bytes.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void_ptr reallocate(
    void_ptr ptr,
    size_t old_size,
    size_t new_size
)
Public Shared Function reallocate (
    ptr As void_ptr,
    old_size As size_t,
    new_size As size_t
) As void_ptr
public:
static void_ptr reallocate(
    void_ptr ptr,
    size_t old_size,
    size_t new_size
)
static member reallocate :
        ptr : void_ptr *
        old_size : size_t *
        new_size : size_t -> void_ptr

Parameters

ptr
Type: Math.Gmp.Nativevoid_ptr
Pointer to previously allocated block.
old_size
Type: Math.Gmp.Nativesize_t
Number of bytes of previously allocated block.
new_size
Type: Math.Gmp.Nativesize_t
New number of bytes of previously allocated block.

Return Value

Type: void_ptr
A previously allocated block ptr of old_size bytes to be new_size bytes.
Remarks

The block may be moved if necessary or if desired, and in that case the smaller of old_size and new_size bytes must be copied to the new location. The return value is a pointer to the resized block, that being the new location if moved or just ptr if not.

ptr is never NULL, it’s always a previously allocated block. new_size may be bigger or smaller than old_size.

The reallocate function parameter old_size is passed for convenience, but of course it can be ignored if not needed by an implementation. The default functions using malloc and friends for instance don’t use it.

See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace
allocate
free


gmp_lib.ZeroMemory Method

gmp_libZeroMemory Method
The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static void ZeroMemory(
    IntPtr dst,
    int length
)
Public Shared Sub ZeroMemory (
    dst As IntPtr,
    length As Integer
)
public:
static void ZeroMemory(
    IntPtr dst,
    int length
)
static member ZeroMemory :
        dst : IntPtr *
        length : int -> unit

Parameters

dst
Type: SystemIntPtr
A pointer to the memory block to be filled with zeros.
length
Type: SystemInt32
The number of bytes to fill with zeros.
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib Fields

gmp_lib Fields

The gmp_lib type exposes the following members.

Fields
Name | Description
gmp_version | The GMP version number in the form “i.j.k”. This release is "6.1.2".
mp_bits_per_limb | The number of bits per limb.
mp_bytes_per_limb | The number of bytes per limb.
mp_uint_per_limb | The number of 32-bit, unsigned integers per limb.
Top
See Also

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.gmp_version Field

gmp_libgmp_version Field
The GMP version number in the form “i.j.k”. This release is "6.1.2".

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly string gmp_version
Public Shared ReadOnly gmp_version As String
public:
static initonly String^ gmp_version
static val gmp_version: string

Field Value

Type: String
Examples
C#
VB
C++
F#
Copy
string version = gmp_lib.gmp_version;
Assert.AreEqual(version, "6.1.2");
Dim version As String = gmp_lib.gmp_version
Assert.AreEqual(version, "6.1.2")

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace


gmp_lib.mp_bits_per_limb Field

gmp_libmp_bits_per_limb Field
The number of bits per limb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly int mp_bits_per_limb
Public Shared ReadOnly mp_bits_per_limb As Integer
public:
static initonly int mp_bits_per_limb
static val mp_bits_per_limb: int

Field Value

Type: Int32
Examples
C#
VB
C++
F#
Copy
int bitsPerLimb = gmp_lib.mp_bits_per_limb;
Assert.AreEqual(bitsPerLimb, IntPtr.Size * 8);
Dim bitsPerLimb As Integer = gmp_lib.mp_bits_per_limb
Assert.AreEqual(bitsPerLimb, IntPtr.Size * 8)

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mp_bytes_per_limb
mp_uint_per_limb


gmp_lib.mp_bytes_per_limb Field

gmp_libmp_bytes_per_limb Field
The number of bytes per limb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly mp_size_t mp_bytes_per_limb
Public Shared ReadOnly mp_bytes_per_limb As mp_size_t
public:
static initonly mp_size_t mp_bytes_per_limb
static val mp_bytes_per_limb: mp_size_t

Field Value

Type: mp_size_t
Examples
C#
VB
C++
F#
Copy
mp_size_t bytesPerLimb = gmp_lib.mp_bytes_per_limb;
Assert.AreEqual(bytesPerLimb, (mp_size_t)IntPtr.Size);
Dim bytesPerLimb As mp_size_t = gmp_lib.mp_bytes_per_limb
Assert.AreEqual(bytesPerLimb, DirectCast(IntPtr.Size, mp_size_t))

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mp_bits_per_limb
mp_uint_per_limb


gmp_lib.mp_uint_per_limb Field

gmp_libmp_uint_per_limb Field
The number of 32-bit, unsigned integers per limb.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly mp_size_t mp_uint_per_limb
Public Shared ReadOnly mp_uint_per_limb As mp_size_t
public:
static initonly mp_size_t mp_uint_per_limb
static val mp_uint_per_limb: mp_size_t

Field Value

Type: mp_size_t
Examples
C#
VB
C++
F#
Copy
mp_size_t uintsPerLimb = gmp_lib.mp_uint_per_limb;
Assert.AreEqual(uintsPerLimb, (mp_size_t)(IntPtr.Size / 4));
Dim uintsPerLimb As mp_size_t = gmp_lib.mp_uint_per_limb
Assert.AreEqual(uintsPerLimb, DirectCast(IntPtr.Size / 4, mp_size_t))

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

Reference

gmp_lib Class
Math.Gmp.Native Namespace
mp_bits_per_limb
mp_bytes_per_limb


gmp_randstate_t Class

gmp_randstate_t Class
Represents the state of a random number generator.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativegmp_randstate_t

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class gmp_randstate_t
Public Class gmp_randstate_t
public ref class gmp_randstate_t
type gmp_randstate_t =  class end

The gmp_randstate_t type exposes the following members.

Constructors
 | Name | Description
Public method | gmp_randstate_t | Creates a new random number generator state.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Get unmanaged memory pointer to the state of a random number generator.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace


gmp_randstate_t Constructor

gmp_randstate_t Constructor
Creates a new random number generator state.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public gmp_randstate_t()
Public Sub New
public:
gmp_randstate_t()
new : unit -> gmp_randstate_t
Remarks

When done with the random number generator state, unmanaged memory must be released with free.

See Also

Reference

gmp_randstate_t Class
Math.Gmp.Native Namespace


gmp_randstate_t Methods

gmp_randstate_t Methods

The gmp_randstate_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Get unmanaged memory pointer to the state of a random number generator.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

gmp_randstate_t Class
Math.Gmp.Native Namespace


gmp_randstate_t.ToIntPtr Method

gmp_randstate_tToIntPtr Method
Get unmanaged memory pointer to the state of a random number generator.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
The unmanaged memory pointer to the state of a random number generator.
See Also

Reference

gmp_randstate_t Class
Math.Gmp.Native Namespace


mp_base Class

mp_base Class
Provides common functionality to mpz_t, mpf_t, and gmp_randstate_t.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativemp_base
Math.Gmp.Nativempf_t
Math.Gmp.Nativempz_t

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class mp_base
Public Class mp_base
public ref class mp_base
type mp_base =  class end

The mp_base type exposes the following members.

Constructors
 | Name | Description
Public method | mp_base | Initializes a new instance of the mp_base class
Top
Properties
 | Name | Description
Public property | _mp_d | A pointer to an array of limbs which is the magnitude.
Public property | _mp_d_intptr | Gets or sets the pointer to limbs in unmanaged memory.
Public property | _mp_size | The number of limbs.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory.
Top
See Also

Reference

Math.Gmp.Native Namespace


mp_base Constructor

mp_base Constructor
Initializes a new instance of the mp_base class

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_base()
Public Sub New
public:
mp_base()
new : unit -> mp_base
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base Properties

mp_base Properties

The mp_base type exposes the following members.

Properties
 | Name | Description
Public property | _mp_d | A pointer to an array of limbs which is the magnitude.
Public property | _mp_d_intptr | Gets or sets the pointer to limbs in unmanaged memory.
Public property | _mp_size | The number of limbs.
Top
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base._mp_d Property

mp_base_mp_d Property
A pointer to an array of limbs which is the magnitude.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public virtual mp_ptr _mp_d { get; }
Public Overridable ReadOnly Property _mp_d As mp_ptr
    Get
public:
virtual property mp_ptr^ _mp_d {
    mp_ptr^ get ();
}
abstract _mp_d : mp_ptr with get
override _mp_d : mp_ptr with get

Property Value

Type: mp_ptr
Remarks

In mpz_t:

A pointer to an array of limbs which is the magnitude. These are stored “little endian” as per the mpn functions, so _mp_d[0] is the least significant limb and _mp_d[ABS(_mp_size) - 1] is the most significant. Whenever _mp_size is non-zero, the most significant limb is non-zero.

Currently there’s always at least one limb allocated, so for instance gmp_lib.mpz_set_ui never needs to reallocate, and gmp_lib.mpz_get_ui can fetch _mp_d[0] unconditionally (though its value is then only wanted if _mp_size is non-zero).

In mpz_t:

A pointer to the array of limbs which is the absolute value of the mantissa. These are stored "little endian" as per the mpn functions, so _mp_d[0] is the least significant limb and _mp_d[ABS(_mp_size)-1] the most significant.

The most significant limb is always non-zero, but there are no other restrictions on its value, in particular the highest 1 bit can be anywhere within the limb.

_mp_prec + 1 limbs are allocated to mp_base._mp_d, the extra limb being for convenience (see below). There are no reallocations during a calculation, only in a change of precision with gmp_lib.mpf_set_prec.

See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base._mp_d_intptr Property

mp_base_mp_d_intptr Property
Gets or sets the pointer to limbs in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public virtual IntPtr _mp_d_intptr { get; set; }
Public Overridable Property _mp_d_intptr As IntPtr
    Get
    Set
public:
virtual property IntPtr _mp_d_intptr {
    IntPtr get ();
    void set (IntPtr value);
}
abstract _mp_d_intptr : IntPtr with get, set
override _mp_d_intptr : IntPtr with get, set

Property Value

Type: IntPtr
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base._mp_size Property

mp_base_mp_size Property
The number of limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public virtual mp_size_t _mp_size { get; set; }
Public Overridable Property _mp_size As mp_size_t
    Get
    Set
public:
virtual property mp_size_t _mp_size {
    mp_size_t get ();
    void set (mp_size_t value);
}
abstract _mp_size : mp_size_t with get, set
override _mp_size : mp_size_t with get, set

Property Value

Type: mp_size_t
Remarks
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base Methods

mp_base Methods

The mp_base type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base Fields

mp_base Fields

The mp_base type exposes the following members.

Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory.
Top
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_base.Pointer Field

mp_basePointer Field
Pointer to limbs in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr Pointer
Public Pointer As IntPtr
public:
IntPtr Pointer
val mutable Pointer: IntPtr

Field Value

Type: IntPtr
See Also

Reference

mp_base Class
Math.Gmp.Native Namespace


mp_bitcnt_t Structure

mp_bitcnt_t Structure
Represents a count of bits.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct mp_bitcnt_t
Public Structure mp_bitcnt_t
public value class mp_bitcnt_t
[<SealedAttribute>]
type mp_bitcnt_t =  struct end

The mp_bitcnt_t type exposes the following members.

Constructors
 | Name | Description
Public method | mp_bitcnt_t | Creates a new mp_bitcnt_t, and sets its value.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_bitcnt_t) | Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_bitcnt_t. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to mp_bitcnt_t) | Converts an Int16 value to an mp_bitcnt_t value.
(Int32 to mp_bitcnt_t) | Converts an Int32 value to an mp_bitcnt_t value.
(Int64 to mp_bitcnt_t) | Converts an Int64 value to a mp_bitcnt_t value.
(SByte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt64 to mp_bitcnt_t) | Converts a UInt64 value to an mp_bitcnt_t value.
(mp_bitcnt_t to Byte) | Converts an mp_bitcnt_t value to a Byte value.
(mp_bitcnt_t to SByte) | Converts an mp_bitcnt_t value to an SByte value.
(mp_bitcnt_t to UInt16) | Converts an mp_bitcnt_t value to a UInt16 value.
(mp_bitcnt_t to Int16) | Converts an mp_bitcnt_t value to an Int16 value.
(mp_bitcnt_t to Int32) | Converts an mp_bitcnt_t value to an Int32 value.
(Byte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt16 to mp_bitcnt_t) | Converts a UInt16 value to an mp_bitcnt_t value.
(UInt32 to mp_bitcnt_t) | Converts a UInt32 value to an mp_bitcnt_t value.
(mp_bitcnt_t to UInt32) | Converts an mp_bitcnt_t value to a UInt32 value.
(mp_bitcnt_t to UInt64) | Converts an mp_bitcnt_t value to a UInt64 value.
(mp_bitcnt_t to Int64) | Converts an mp_bitcnt_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | The mp_bitcnt_t value.
Top
Remarks

Counts of bits of a multi-precision number are represented in the C type mp_bitcnt_t. Currently this is always an unsigned long, but on some systems it will be an unsigned long long in the future.

In .NET, this is an unsigned 32-bit integer.

See Also

Reference

Math.Gmp.Native Namespace
mpf_t
mpq_t
mpz_t


mp_bitcnt_t Constructor

mp_bitcnt_t Constructor
Creates a new mp_bitcnt_t, and sets its value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_bitcnt_t(
    uint value
)
Public Sub New (
    value As UInteger
)
public:
mp_bitcnt_t(
    unsigned int value
)
new :
        value : uint32 -> mp_bitcnt_t

Parameters

value
Type: SystemUInt32
The value of the new mp_bitcnt_t.
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Methods

mp_bitcnt_t Methods

The mp_bitcnt_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_bitcnt_t) | Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_bitcnt_t. (Overrides ValueTypeToString.)
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t.Equals Method

mp_bitcnt_tEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_bitcnt_t) | Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value.
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t.Equals Method (Object)

mp_bitcnt_tEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of mp_bitcnt_t and equals the value of this instance; otherwise, False.
See Also

Reference

mp_bitcnt_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_bitcnt_t.Equals Method (mp_bitcnt_t)

mp_bitcnt_tEquals Method (mp_bitcnt_t)
Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    mp_bitcnt_t other
)
Public Function Equals (
    other As mp_bitcnt_t
) As Boolean
public:
bool Equals(
    mp_bitcnt_t other
)
member Equals :
        other : mp_bitcnt_t -> bool

Parameters

other
Type: Math.Gmp.Nativemp_bitcnt_t
A mp_bitcnt_t value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

mp_bitcnt_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_bitcnt_t.GetHashCode Method

mp_bitcnt_tGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t.ToString Method

mp_bitcnt_tToString Method
Gets the string representation of the mp_bitcnt_t.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the mp_bitcnt_t.
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Operators and Type Conversions

mp_bitcnt_t Operators and Type Conversions

The mp_bitcnt_t type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to mp_bitcnt_t) | Converts an Int16 value to an mp_bitcnt_t value.
(Int32 to mp_bitcnt_t) | Converts an Int32 value to an mp_bitcnt_t value.
(Int64 to mp_bitcnt_t) | Converts an Int64 value to a mp_bitcnt_t value.
(SByte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt64 to mp_bitcnt_t) | Converts a UInt64 value to an mp_bitcnt_t value.
(mp_bitcnt_t to Byte) | Converts an mp_bitcnt_t value to a Byte value.
(mp_bitcnt_t to SByte) | Converts an mp_bitcnt_t value to an SByte value.
(mp_bitcnt_t to UInt16) | Converts an mp_bitcnt_t value to a UInt16 value.
(mp_bitcnt_t to Int16) | Converts an mp_bitcnt_t value to an Int16 value.
(mp_bitcnt_t to Int32) | Converts an mp_bitcnt_t value to an Int32 value.
(Byte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt16 to mp_bitcnt_t) | Converts a UInt16 value to an mp_bitcnt_t value.
(UInt32 to mp_bitcnt_t) | Converts a UInt32 value to an mp_bitcnt_t value.
(mp_bitcnt_t to UInt32) | Converts an mp_bitcnt_t value to a UInt32 value.
(mp_bitcnt_t to UInt64) | Converts an mp_bitcnt_t value to a UInt64 value.
(mp_bitcnt_t to Int64) | Converts an mp_bitcnt_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t.Equality Operator

mp_bitcnt_tEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    mp_bitcnt_t value1,
    mp_bitcnt_t value2
)
Public Shared Operator = (
    value1 As mp_bitcnt_t,
    value2 As mp_bitcnt_t
) As Boolean
public:
static bool operator ==(
    mp_bitcnt_t value1,
    mp_bitcnt_t value2
)
static let inline (=)
        value1 : mp_bitcnt_t *
        value2 : mp_bitcnt_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_bitcnt_t
A mp_bitcnt_t value.
value2
Type: Math.Gmp.Nativemp_bitcnt_t
A mp_bitcnt_t value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion Operators

mp_bitcnt_t Conversion Operators
Overload List
Name | Description
(Int16 to mp_bitcnt_t) | Converts an Int16 value to an mp_bitcnt_t value.
(Int32 to mp_bitcnt_t) | Converts an Int32 value to an mp_bitcnt_t value.
(Int64 to mp_bitcnt_t) | Converts an Int64 value to a mp_bitcnt_t value.
(SByte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt64 to mp_bitcnt_t) | Converts a UInt64 value to an mp_bitcnt_t value.
(mp_bitcnt_t to Byte) | Converts an mp_bitcnt_t value to a Byte value.
(mp_bitcnt_t to SByte) | Converts an mp_bitcnt_t value to an SByte value.
(mp_bitcnt_t to UInt16) | Converts an mp_bitcnt_t value to a UInt16 value.
(mp_bitcnt_t to Int16) | Converts an mp_bitcnt_t value to an Int16 value.
(mp_bitcnt_t to Int32) | Converts an mp_bitcnt_t value to an Int32 value.
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (Int16 to mp_bitcnt_t)

mp_bitcnt_t Conversion (Int16 to mp_bitcnt_t)
Converts an Int16 value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_bitcnt_t (
    short value
)
Public Shared Narrowing Operator CType (
    value As Short
) As mp_bitcnt_t
static explicit operator mp_bitcnt_t (
    short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt16
An Int16 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (Int32 to mp_bitcnt_t)

mp_bitcnt_t Conversion (Int32 to mp_bitcnt_t)
Converts an Int32 value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_bitcnt_t (
    int value
)
Public Shared Narrowing Operator CType (
    value As Integer
) As mp_bitcnt_t
static explicit operator mp_bitcnt_t (
    int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt32
An Int32 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (Int64 to mp_bitcnt_t)

mp_bitcnt_t Conversion (Int64 to mp_bitcnt_t)
Converts an Int64 value to a mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_bitcnt_t (
    long value
)
Public Shared Narrowing Operator CType (
    value As Long
) As mp_bitcnt_t
static explicit operator mp_bitcnt_t (
    long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt64
An Int64 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (SByte to mp_bitcnt_t)

mp_bitcnt_t Conversion (SByte to mp_bitcnt_t)
Converts a Byte value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_bitcnt_t (
    sbyte value
)
Public Shared Narrowing Operator CType (
    value As SByte
) As mp_bitcnt_t
static explicit operator mp_bitcnt_t (
    signed char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemSByte
A Byte value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (UInt64 to mp_bitcnt_t)

mp_bitcnt_t Conversion (UInt64 to mp_bitcnt_t)
Converts a UInt64 value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_bitcnt_t (
    ulong value
)
Public Shared Narrowing Operator CType (
    value As ULong
) As mp_bitcnt_t
static explicit operator mp_bitcnt_t (
    unsigned long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt64
A UInt64 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Byte)

mp_bitcnt_t Conversion (mp_bitcnt_t to Byte)
Converts an mp_bitcnt_t value to a Byte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator byte (
    mp_bitcnt_t value
)
Public Shared Narrowing Operator CType (
    value As mp_bitcnt_t
) As Byte
static explicit operator unsigned char (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: Byte
A Byte value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to SByte)

mp_bitcnt_t Conversion (mp_bitcnt_t to SByte)
Converts an mp_bitcnt_t value to an SByte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator sbyte (
    mp_bitcnt_t value
)
Public Shared Narrowing Operator CType (
    value As mp_bitcnt_t
) As SByte
static explicit operator signed char (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An SByte value.

Return Value

Type: SByte
An Byte value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to UInt16)

mp_bitcnt_t Conversion (mp_bitcnt_t to UInt16)
Converts an mp_bitcnt_t value to a UInt16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ushort (
    mp_bitcnt_t value
)
Public Shared Narrowing Operator CType (
    value As mp_bitcnt_t
) As UShort
static explicit operator unsigned short (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: UInt16
A UInt16 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Int16)

mp_bitcnt_t Conversion (mp_bitcnt_t to Int16)
Converts an mp_bitcnt_t value to an Int16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator short (
    mp_bitcnt_t value
)
Public Shared Narrowing Operator CType (
    value As mp_bitcnt_t
) As Short
static explicit operator short (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: Int16
An Int16 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Int32)

mp_bitcnt_t Conversion (mp_bitcnt_t to Int32)
Converts an mp_bitcnt_t value to an Int32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator int (
    mp_bitcnt_t value
)
Public Shared Narrowing Operator CType (
    value As mp_bitcnt_t
) As Integer
static explicit operator int (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: Int32
An Int32 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion Operators

mp_bitcnt_t Conversion Operators
Overload List
Name | Description
(Byte to mp_bitcnt_t) | Converts a Byte value to an mp_bitcnt_t value.
(UInt16 to mp_bitcnt_t) | Converts a UInt16 value to an mp_bitcnt_t value.
(UInt32 to mp_bitcnt_t) | Converts a UInt32 value to an mp_bitcnt_t value.
(mp_bitcnt_t to UInt32) | Converts an mp_bitcnt_t value to a UInt32 value.
(mp_bitcnt_t to UInt64) | Converts an mp_bitcnt_t value to a UInt64 value.
(mp_bitcnt_t to Int64) | Converts an mp_bitcnt_t value to an Int64 value.
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (Byte to mp_bitcnt_t)

mp_bitcnt_t Conversion (Byte to mp_bitcnt_t)
Converts a Byte value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_bitcnt_t (
    byte value
)
Public Shared Widening Operator CType (
    value As Byte
) As mp_bitcnt_t
static implicit operator mp_bitcnt_t (
    unsigned char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemByte
A Byte value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (UInt16 to mp_bitcnt_t)

mp_bitcnt_t Conversion (UInt16 to mp_bitcnt_t)
Converts a UInt16 value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_bitcnt_t (
    ushort value
)
Public Shared Widening Operator CType (
    value As UShort
) As mp_bitcnt_t
static implicit operator mp_bitcnt_t (
    unsigned short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt16
A UInt16 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (UInt32 to mp_bitcnt_t)

mp_bitcnt_t Conversion (UInt32 to mp_bitcnt_t)
Converts a UInt32 value to an mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_bitcnt_t (
    uint value
)
Public Shared Widening Operator CType (
    value As UInteger
) As mp_bitcnt_t
static implicit operator mp_bitcnt_t (
    unsigned int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt32
A UInt32 value.

Return Value

Type: mp_bitcnt_t
An mp_bitcnt_t value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to UInt32)

mp_bitcnt_t Conversion (mp_bitcnt_t to UInt32)
Converts an mp_bitcnt_t value to a UInt32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator uint (
    mp_bitcnt_t value
)
Public Shared Widening Operator CType (
    value As mp_bitcnt_t
) As UInteger
static implicit operator unsigned int (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: UInt32
A UInt32 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to UInt64)

mp_bitcnt_t Conversion (mp_bitcnt_t to UInt64)
Converts an mp_bitcnt_t value to a UInt64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator ulong (
    mp_bitcnt_t value
)
Public Shared Widening Operator CType (
    value As mp_bitcnt_t
) As ULong
static implicit operator unsigned long long (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: UInt64
A UInt64 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to Int64)

mp_bitcnt_t Conversion (mp_bitcnt_t to Int64)
Converts an mp_bitcnt_t value to an Int64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator long (
    mp_bitcnt_t value
)
Public Shared Widening Operator CType (
    value As mp_bitcnt_t
) As Long
static implicit operator long long (
    mp_bitcnt_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_bitcnt_t
An mp_bitcnt_t value.

Return Value

Type: Int64
An Int64 value.
See Also

Reference

mp_bitcnt_t Structure
Overload
Math.Gmp.Native Namespace


mp_bitcnt_t.Inequality Operator

mp_bitcnt_tInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    mp_bitcnt_t value1,
    mp_bitcnt_t value2
)
Public Shared Operator <> (
    value1 As mp_bitcnt_t,
    value2 As mp_bitcnt_t
) As Boolean
public:
static bool operator !=(
    mp_bitcnt_t value1,
    mp_bitcnt_t value2
)
static let inline (<>)
        value1 : mp_bitcnt_t *
        value2 : mp_bitcnt_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_bitcnt_t
A mp_bitcnt_t value.
value2
Type: Math.Gmp.Nativemp_bitcnt_t
A mp_bitcnt_t value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t Fields

mp_bitcnt_t Fields

The mp_bitcnt_t type exposes the following members.

Fields
 | Name | Description
Public field | Value | The mp_bitcnt_t value.
Top
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_bitcnt_t.Value Field

mp_bitcnt_tValue Field
The mp_bitcnt_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public uint Value
Public Value As UInteger
public:
unsigned int Value
val mutable Value: uint32

Field Value

Type: UInt32
See Also

Reference

mp_bitcnt_t Structure
Math.Gmp.Native Namespace


mp_exp_t Structure

mp_exp_t Structure
Represents the exponent of a floating-point number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct mp_exp_t
Public Structure mp_exp_t
public value class mp_exp_t
[<SealedAttribute>]
type mp_exp_t =  struct end

The mp_exp_t type exposes the following members.

Constructors
 | Name | Description
Public method | mp_exp_t | Creates a new mp_exp_t, and sets its value.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_exp_t) | Returns a value indicating whether this instance is equal to a specified mp_exp_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_exp_t. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int64 to mp_exp_t) | Converts an Int64 value to a mp_exp_t value.
(UInt32 to mp_exp_t) | Converts a UInt32 value to an mp_exp_t value.
(UInt64 to mp_exp_t) | Converts a UInt64 value to an mp_exp_t value.
(mp_exp_t to Byte) | Converts an mp_exp_t value to a Byte value.
(mp_exp_t to SByte) | Converts an mp_exp_t value to an SByte value.
(mp_exp_t to UInt16) | Converts an mp_exp_t value to a UInt16 value.
(mp_exp_t to Int16) | Converts an mp_exp_t value to an Int16 value.
(mp_exp_t to UInt32) | Converts an mp_exp_t value to a UInt32 value.
(mp_exp_t to UInt64) | Converts an mp_exp_t value to a UInt64 value.
(Byte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(Int16 to mp_exp_t) | Converts an Int16 value to an mp_exp_t value.
(Int32 to mp_exp_t) | Converts an Int32 value to an mp_exp_t value.
(SByte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(UInt16 to mp_exp_t) | Converts a UInt16 value to an mp_exp_t value.
(mp_exp_t to Int32) | Converts an mp_exp_t value to an Int32 value.
(mp_exp_t to Int64) | Converts an mp_exp_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | The mp_exp_t value.
Top
Remarks

The floating point functions accept and return exponents in the C type mp_exp_t. Currently this is usually a long, but on some systems it’s an int for efficiency.

In .Net, this is a 32-bit integer.

See Also

Reference

Math.Gmp.Native Namespace


mp_exp_t Constructor

mp_exp_t Constructor
Creates a new mp_exp_t, and sets its value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_exp_t(
    int value
)
Public Sub New (
    value As Integer
)
public:
mp_exp_t(
    int value
)
new :
        value : int -> mp_exp_t

Parameters

value
Type: SystemInt32
The value of the new mp_exp_t.
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Methods

mp_exp_t Methods

The mp_exp_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_exp_t) | Returns a value indicating whether this instance is equal to a specified mp_exp_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_exp_t. (Overrides ValueTypeToString.)
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t.Equals Method

mp_exp_tEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_exp_t) | Returns a value indicating whether this instance is equal to a specified mp_exp_t value.
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t.Equals Method (Object)

mp_exp_tEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of mp_exp_t and equals the value of this instance; otherwise, False.
See Also

Reference

mp_exp_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_exp_t.Equals Method (mp_exp_t)

mp_exp_tEquals Method (mp_exp_t)
Returns a value indicating whether this instance is equal to a specified mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    mp_exp_t other
)
Public Function Equals (
    other As mp_exp_t
) As Boolean
public:
bool Equals(
    mp_exp_t other
)
member Equals :
        other : mp_exp_t -> bool

Parameters

other
Type: Math.Gmp.Nativemp_exp_t
A mp_exp_t value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

mp_exp_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_exp_t.GetHashCode Method

mp_exp_tGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t.ToString Method

mp_exp_tToString Method
Gets the string representation of the mp_exp_t.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the mp_exp_t.
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Operators and Type Conversions

mp_exp_t Operators and Type Conversions

The mp_exp_t type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int64 to mp_exp_t) | Converts an Int64 value to a mp_exp_t value.
(UInt32 to mp_exp_t) | Converts a UInt32 value to an mp_exp_t value.
(UInt64 to mp_exp_t) | Converts a UInt64 value to an mp_exp_t value.
(mp_exp_t to Byte) | Converts an mp_exp_t value to a Byte value.
(mp_exp_t to SByte) | Converts an mp_exp_t value to an SByte value.
(mp_exp_t to UInt16) | Converts an mp_exp_t value to a UInt16 value.
(mp_exp_t to Int16) | Converts an mp_exp_t value to an Int16 value.
(mp_exp_t to UInt32) | Converts an mp_exp_t value to a UInt32 value.
(mp_exp_t to UInt64) | Converts an mp_exp_t value to a UInt64 value.
(Byte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(Int16 to mp_exp_t) | Converts an Int16 value to an mp_exp_t value.
(Int32 to mp_exp_t) | Converts an Int32 value to an mp_exp_t value.
(SByte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(UInt16 to mp_exp_t) | Converts a UInt16 value to an mp_exp_t value.
(mp_exp_t to Int32) | Converts an mp_exp_t value to an Int32 value.
(mp_exp_t to Int64) | Converts an mp_exp_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t.Equality Operator

mp_exp_tEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    mp_exp_t value1,
    mp_exp_t value2
)
Public Shared Operator = (
    value1 As mp_exp_t,
    value2 As mp_exp_t
) As Boolean
public:
static bool operator ==(
    mp_exp_t value1,
    mp_exp_t value2
)
static let inline (=)
        value1 : mp_exp_t *
        value2 : mp_exp_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_exp_t
A mp_exp_t value.
value2
Type: Math.Gmp.Nativemp_exp_t
A mp_exp_t value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion Operators

mp_exp_t Conversion Operators
Overload List
Name | Description
(Int64 to mp_exp_t) | Converts an Int64 value to a mp_exp_t value.
(UInt32 to mp_exp_t) | Converts a UInt32 value to an mp_exp_t value.
(UInt64 to mp_exp_t) | Converts a UInt64 value to an mp_exp_t value.
(mp_exp_t to Byte) | Converts an mp_exp_t value to a Byte value.
(mp_exp_t to SByte) | Converts an mp_exp_t value to an SByte value.
(mp_exp_t to UInt16) | Converts an mp_exp_t value to a UInt16 value.
(mp_exp_t to Int16) | Converts an mp_exp_t value to an Int16 value.
(mp_exp_t to UInt32) | Converts an mp_exp_t value to a UInt32 value.
(mp_exp_t to UInt64) | Converts an mp_exp_t value to a UInt64 value.
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (Int64 to mp_exp_t)

mp_exp_t Conversion (Int64 to mp_exp_t)
Converts an Int64 value to a mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_exp_t (
    long value
)
Public Shared Narrowing Operator CType (
    value As Long
) As mp_exp_t
static explicit operator mp_exp_t (
    long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt64
An Int64 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (UInt32 to mp_exp_t)

mp_exp_t Conversion (UInt32 to mp_exp_t)
Converts a UInt32 value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_exp_t (
    uint value
)
Public Shared Narrowing Operator CType (
    value As UInteger
) As mp_exp_t
static explicit operator mp_exp_t (
    unsigned int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt32
A UInt32 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (UInt64 to mp_exp_t)

mp_exp_t Conversion (UInt64 to mp_exp_t)
Converts a UInt64 value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_exp_t (
    ulong value
)
Public Shared Narrowing Operator CType (
    value As ULong
) As mp_exp_t
static explicit operator mp_exp_t (
    unsigned long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt64
A UInt64 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to Byte)

mp_exp_t Conversion (mp_exp_t to Byte)
Converts an mp_exp_t value to a Byte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator byte (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As Byte
static explicit operator unsigned char (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: Byte
A Byte value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to SByte)

mp_exp_t Conversion (mp_exp_t to SByte)
Converts an mp_exp_t value to an SByte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator sbyte (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As SByte
static explicit operator signed char (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: SByte
An SByte value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to UInt16)

mp_exp_t Conversion (mp_exp_t to UInt16)
Converts an mp_exp_t value to a UInt16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ushort (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As UShort
static explicit operator unsigned short (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: UInt16
A UInt16 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to Int16)

mp_exp_t Conversion (mp_exp_t to Int16)
Converts an mp_exp_t value to an Int16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator short (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As Short
static explicit operator short (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: Int16
An Int16 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to UInt32)

mp_exp_t Conversion (mp_exp_t to UInt32)
Converts an mp_exp_t value to a UInt32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator uint (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As UInteger
static explicit operator unsigned int (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: UInt32
A UInt32 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Explicit Conversion (mp_exp_t to UInt64)

mp_exp_t Conversion (mp_exp_t to UInt64)
Converts an mp_exp_t value to a UInt64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ulong (
    mp_exp_t value
)
Public Shared Narrowing Operator CType (
    value As mp_exp_t
) As ULong
static explicit operator unsigned long long (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: UInt64
A UInt64 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion Operators

mp_exp_t Conversion Operators
Overload List
Name | Description
(Byte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(Int16 to mp_exp_t) | Converts an Int16 value to an mp_exp_t value.
(Int32 to mp_exp_t) | Converts an Int32 value to an mp_exp_t value.
(SByte to mp_exp_t) | Converts a Byte value to an mp_exp_t value.
(UInt16 to mp_exp_t) | Converts a UInt16 value to an mp_exp_t value.
(mp_exp_t to Int32) | Converts an mp_exp_t value to an Int32 value.
(mp_exp_t to Int64) | Converts an mp_exp_t value to an Int64 value.
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (Byte to mp_exp_t)

mp_exp_t Conversion (Byte to mp_exp_t)
Converts a Byte value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_exp_t (
    byte value
)
Public Shared Widening Operator CType (
    value As Byte
) As mp_exp_t
static implicit operator mp_exp_t (
    unsigned char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemByte
A Byte value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (Int16 to mp_exp_t)

mp_exp_t Conversion (Int16 to mp_exp_t)
Converts an Int16 value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_exp_t (
    short value
)
Public Shared Widening Operator CType (
    value As Short
) As mp_exp_t
static implicit operator mp_exp_t (
    short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt16
An Int16 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (Int32 to mp_exp_t)

mp_exp_t Conversion (Int32 to mp_exp_t)
Converts an Int32 value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_exp_t (
    int value
)
Public Shared Widening Operator CType (
    value As Integer
) As mp_exp_t
static implicit operator mp_exp_t (
    int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt32
An Int32 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (SByte to mp_exp_t)

mp_exp_t Conversion (SByte to mp_exp_t)
Converts a Byte value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_exp_t (
    sbyte value
)
Public Shared Widening Operator CType (
    value As SByte
) As mp_exp_t
static implicit operator mp_exp_t (
    signed char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemSByte
A Byte value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (UInt16 to mp_exp_t)

mp_exp_t Conversion (UInt16 to mp_exp_t)
Converts a UInt16 value to an mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_exp_t (
    ushort value
)
Public Shared Widening Operator CType (
    value As UShort
) As mp_exp_t
static implicit operator mp_exp_t (
    unsigned short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt16
A UInt16 value.

Return Value

Type: mp_exp_t
An mp_exp_t value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (mp_exp_t to Int32)

mp_exp_t Conversion (mp_exp_t to Int32)
Converts an mp_exp_t value to an Int32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator int (
    mp_exp_t value
)
Public Shared Widening Operator CType (
    value As mp_exp_t
) As Integer
static implicit operator int (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: Int32
An Int32 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t Implicit Conversion (mp_exp_t to Int64)

mp_exp_t Conversion (mp_exp_t to Int64)
Converts an mp_exp_t value to an Int64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator long (
    mp_exp_t value
)
Public Shared Widening Operator CType (
    value As mp_exp_t
) As Long
static implicit operator long long (
    mp_exp_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_exp_t
An mp_exp_t value.

Return Value

Type: Int64
An Int64 value.
See Also

Reference

mp_exp_t Structure
Overload
Math.Gmp.Native Namespace


mp_exp_t.Inequality Operator

mp_exp_tInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    mp_exp_t value1,
    mp_exp_t value2
)
Public Shared Operator <> (
    value1 As mp_exp_t,
    value2 As mp_exp_t
) As Boolean
public:
static bool operator !=(
    mp_exp_t value1,
    mp_exp_t value2
)
static let inline (<>)
        value1 : mp_exp_t *
        value2 : mp_exp_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_exp_t
A mp_exp_t value.
value2
Type: Math.Gmp.Nativemp_exp_t
A mp_exp_t value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t Fields

mp_exp_t Fields

The mp_exp_t type exposes the following members.

Fields
 | Name | Description
Public field | Value | The mp_exp_t value.
Top
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_exp_t.Value Field

mp_exp_tValue Field
The mp_exp_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public int Value
Public Value As Integer
public:
int Value
val mutable Value: int

Field Value

Type: Int32
See Also

Reference

mp_exp_t Structure
Math.Gmp.Native Namespace


mp_limb_t Structure

mp_limb_t Structure
Represents a part of a multiple precision number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct mp_limb_t
Public Structure mp_limb_t
public value class mp_limb_t
[<SealedAttribute>]
type mp_limb_t =  struct end

The mp_limb_t type exposes the following members.

Constructors
 | Name | Description
Public method | mp_limb_t | Creates a new mp_limb_t, and sets its value.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_limb_t) | Returns a value indicating whether this instance is equal to a specified mp_limb_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_limb_t. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to mp_limb_t) | Converts an Int16 value to an mp_limb_t value.
(Int32 to mp_limb_t) | Converts an Int32 value to an mp_limb_t value.
(Int64 to mp_limb_t) | Converts an Int64 value to an mp_limb_t value.
(SByte to mp_limb_t) | Converts a SByte value to an mp_limb_t value.
(mp_limb_t to Byte) | Converts a mp_limb_t value to a Byte value.
(mp_limb_t to SByte) | Converts a mp_limb_t value to an SByte value.
(mp_limb_t to UInt16) | Converts a mp_limb_t value to a UInt16 value.
(mp_limb_t to Int16) | Converts a mp_limb_t value to an Int16 value.
(mp_limb_t to UInt32) | Converts a mp_limb_t value to a UInt32 value.
(mp_limb_t to Int32) | Converts a mp_limb_t value to an Int32 value.
(mp_limb_t to Int64) | Converts a mp_limb_t value to an Int64 value.
(Byte to mp_limb_t) | Converts a Byte value to an mp_limb_t value.
(UInt16 to mp_limb_t) | Converts a UInt16 value to an mp_limb_t value.
(UInt32 to mp_limb_t) | Converts a UInt32 value to an mp_limb_t value.
(UInt64 to mp_limb_t) | Converts a UInt64 value to an mp_limb_t value.
(mp_limb_t to UInt64) | Converts a mp_limb_t value to a UInt64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | The mp_limb_t value.
Top
Remarks

A limb means the part of a multi-precision number that fits in a single machine word. (We chose this word because a limb of the human body is analogous to a digit, only larger, and containing several digits.) Normally a limb is 32 or 64 bits.

See Also

Reference

Math.Gmp.Native Namespace
mpf_t
mpq_t
mpz_t


mp_limb_t Constructor

mp_limb_t Constructor
Creates a new mp_limb_t, and sets its value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_limb_t(
    ulong value
)
Public Sub New (
    value As ULong
)
public:
mp_limb_t(
    unsigned long long value
)
new :
        value : uint64 -> mp_limb_t

Parameters

value
Type: SystemUInt64
The value of the new mp_limb_t.
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Methods

mp_limb_t Methods

The mp_limb_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_limb_t) | Returns a value indicating whether this instance is equal to a specified mp_limb_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_limb_t. (Overrides ValueTypeToString.)
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t.Equals Method

mp_limb_tEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_limb_t) | Returns a value indicating whether this instance is equal to a specified mp_limb_t value.
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t.Equals Method (Object)

mp_limb_tEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of mp_limb_t and equals the value of this instance; otherwise, False.
See Also

Reference

mp_limb_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_limb_t.Equals Method (mp_limb_t)

mp_limb_tEquals Method (mp_limb_t)
Returns a value indicating whether this instance is equal to a specified mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    mp_limb_t other
)
Public Function Equals (
    other As mp_limb_t
) As Boolean
public:
bool Equals(
    mp_limb_t other
)
member Equals :
        other : mp_limb_t -> bool

Parameters

other
Type: Math.Gmp.Nativemp_limb_t
A mp_limb_t value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

mp_limb_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_limb_t.GetHashCode Method

mp_limb_tGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t.ToString Method

mp_limb_tToString Method
Gets the string representation of the mp_limb_t.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the mp_limb_t.
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Operators and Type Conversions

mp_limb_t Operators and Type Conversions

The mp_limb_t type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to mp_limb_t) | Converts an Int16 value to an mp_limb_t value.
(Int32 to mp_limb_t) | Converts an Int32 value to an mp_limb_t value.
(Int64 to mp_limb_t) | Converts an Int64 value to an mp_limb_t value.
(SByte to mp_limb_t) | Converts a SByte value to an mp_limb_t value.
(mp_limb_t to Byte) | Converts a mp_limb_t value to a Byte value.
(mp_limb_t to SByte) | Converts a mp_limb_t value to an SByte value.
(mp_limb_t to UInt16) | Converts a mp_limb_t value to a UInt16 value.
(mp_limb_t to Int16) | Converts a mp_limb_t value to an Int16 value.
(mp_limb_t to UInt32) | Converts a mp_limb_t value to a UInt32 value.
(mp_limb_t to Int32) | Converts a mp_limb_t value to an Int32 value.
(mp_limb_t to Int64) | Converts a mp_limb_t value to an Int64 value.
(Byte to mp_limb_t) | Converts a Byte value to an mp_limb_t value.
(UInt16 to mp_limb_t) | Converts a UInt16 value to an mp_limb_t value.
(UInt32 to mp_limb_t) | Converts a UInt32 value to an mp_limb_t value.
(UInt64 to mp_limb_t) | Converts a UInt64 value to an mp_limb_t value.
(mp_limb_t to UInt64) | Converts a mp_limb_t value to a UInt64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t.Equality Operator

mp_limb_tEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    mp_limb_t value1,
    mp_limb_t value2
)
Public Shared Operator = (
    value1 As mp_limb_t,
    value2 As mp_limb_t
) As Boolean
public:
static bool operator ==(
    mp_limb_t value1,
    mp_limb_t value2
)
static let inline (=)
        value1 : mp_limb_t *
        value2 : mp_limb_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_limb_t
A mp_limb_t value.
value2
Type: Math.Gmp.Nativemp_limb_t
A mp_limb_t value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion Operators

mp_limb_t Conversion Operators
Overload List
Name | Description
(Int16 to mp_limb_t) | Converts an Int16 value to an mp_limb_t value.
(Int32 to mp_limb_t) | Converts an Int32 value to an mp_limb_t value.
(Int64 to mp_limb_t) | Converts an Int64 value to an mp_limb_t value.
(SByte to mp_limb_t) | Converts a SByte value to an mp_limb_t value.
(mp_limb_t to Byte) | Converts a mp_limb_t value to a Byte value.
(mp_limb_t to SByte) | Converts a mp_limb_t value to an SByte value.
(mp_limb_t to UInt16) | Converts a mp_limb_t value to a UInt16 value.
(mp_limb_t to Int16) | Converts a mp_limb_t value to an Int16 value.
(mp_limb_t to UInt32) | Converts a mp_limb_t value to a UInt32 value.
(mp_limb_t to Int32) | Converts a mp_limb_t value to an Int32 value.
(mp_limb_t to Int64) | Converts a mp_limb_t value to an Int64 value.
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (Int16 to mp_limb_t)

mp_limb_t Conversion (Int16 to mp_limb_t)
Converts an Int16 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_limb_t (
    short value
)
Public Shared Narrowing Operator CType (
    value As Short
) As mp_limb_t
static explicit operator mp_limb_t (
    short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt16
An Int16 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (Int32 to mp_limb_t)

mp_limb_t Conversion (Int32 to mp_limb_t)
Converts an Int32 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_limb_t (
    int value
)
Public Shared Narrowing Operator CType (
    value As Integer
) As mp_limb_t
static explicit operator mp_limb_t (
    int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt32
An Int32 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (Int64 to mp_limb_t)

mp_limb_t Conversion (Int64 to mp_limb_t)
Converts an Int64 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_limb_t (
    long value
)
Public Shared Narrowing Operator CType (
    value As Long
) As mp_limb_t
static explicit operator mp_limb_t (
    long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt64
An Int64 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (SByte to mp_limb_t)

mp_limb_t Conversion (SByte to mp_limb_t)
Converts a SByte value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_limb_t (
    sbyte value
)
Public Shared Narrowing Operator CType (
    value As SByte
) As mp_limb_t
static explicit operator mp_limb_t (
    signed char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemSByte
A SByte value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to Byte)

mp_limb_t Conversion (mp_limb_t to Byte)
Converts a mp_limb_t value to a Byte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator byte (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As Byte
static explicit operator unsigned char (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: Byte
A Byte value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to SByte)

mp_limb_t Conversion (mp_limb_t to SByte)
Converts a mp_limb_t value to an SByte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator sbyte (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As SByte
static explicit operator signed char (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: SByte
An SByte value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to UInt16)

mp_limb_t Conversion (mp_limb_t to UInt16)
Converts a mp_limb_t value to a UInt16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ushort (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As UShort
static explicit operator unsigned short (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: UInt16
A UInt16 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to Int16)

mp_limb_t Conversion (mp_limb_t to Int16)
Converts a mp_limb_t value to an Int16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator short (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As Short
static explicit operator short (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: Int16
An Int16 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to UInt32)

mp_limb_t Conversion (mp_limb_t to UInt32)
Converts a mp_limb_t value to a UInt32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator uint (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As UInteger
static explicit operator unsigned int (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: UInt32
A UInt32 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to Int32)

mp_limb_t Conversion (mp_limb_t to Int32)
Converts a mp_limb_t value to an Int32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator int (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As Integer
static explicit operator int (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: Int32
An Int32 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Explicit Conversion (mp_limb_t to Int64)

mp_limb_t Conversion (mp_limb_t to Int64)
Converts a mp_limb_t value to an Int64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator long (
    mp_limb_t value
)
Public Shared Narrowing Operator CType (
    value As mp_limb_t
) As Long
static explicit operator long long (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: Int64
An Int64 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion Operators

mp_limb_t Conversion Operators
Overload List
Name | Description
(Byte to mp_limb_t) | Converts a Byte value to an mp_limb_t value.
(UInt16 to mp_limb_t) | Converts a UInt16 value to an mp_limb_t value.
(UInt32 to mp_limb_t) | Converts a UInt32 value to an mp_limb_t value.
(UInt64 to mp_limb_t) | Converts a UInt64 value to an mp_limb_t value.
(mp_limb_t to UInt64) | Converts a mp_limb_t value to a UInt64 value.
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion (Byte to mp_limb_t)

mp_limb_t Conversion (Byte to mp_limb_t)
Converts a Byte value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_limb_t (
    byte value
)
Public Shared Widening Operator CType (
    value As Byte
) As mp_limb_t
static implicit operator mp_limb_t (
    unsigned char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemByte
A Byte value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion (UInt16 to mp_limb_t)

mp_limb_t Conversion (UInt16 to mp_limb_t)
Converts a UInt16 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_limb_t (
    ushort value
)
Public Shared Widening Operator CType (
    value As UShort
) As mp_limb_t
static implicit operator mp_limb_t (
    unsigned short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt16
A UInt16 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion (UInt32 to mp_limb_t)

mp_limb_t Conversion (UInt32 to mp_limb_t)
Converts a UInt32 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_limb_t (
    uint value
)
Public Shared Widening Operator CType (
    value As UInteger
) As mp_limb_t
static implicit operator mp_limb_t (
    unsigned int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt32
A UInt32 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion (UInt64 to mp_limb_t)

mp_limb_t Conversion (UInt64 to mp_limb_t)
Converts a UInt64 value to an mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_limb_t (
    ulong value
)
Public Shared Widening Operator CType (
    value As ULong
) As mp_limb_t
static implicit operator mp_limb_t (
    unsigned long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt64
A UInt64 value.

Return Value

Type: mp_limb_t
An mp_limb_t value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t Implicit Conversion (mp_limb_t to UInt64)

mp_limb_t Conversion (mp_limb_t to UInt64)
Converts a mp_limb_t value to a UInt64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator ulong (
    mp_limb_t value
)
Public Shared Widening Operator CType (
    value As mp_limb_t
) As ULong
static implicit operator unsigned long long (
    mp_limb_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_limb_t
An mp_limb_t value.

Return Value

Type: UInt64
A UInt64 value.
See Also

Reference

mp_limb_t Structure
Overload
Math.Gmp.Native Namespace


mp_limb_t.Inequality Operator

mp_limb_tInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    mp_limb_t value1,
    mp_limb_t value2
)
Public Shared Operator <> (
    value1 As mp_limb_t,
    value2 As mp_limb_t
) As Boolean
public:
static bool operator !=(
    mp_limb_t value1,
    mp_limb_t value2
)
static let inline (<>)
        value1 : mp_limb_t *
        value2 : mp_limb_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_limb_t
A mp_limb_t value.
value2
Type: Math.Gmp.Nativemp_limb_t
A mp_limb_t value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t Fields

mp_limb_t Fields

The mp_limb_t type exposes the following members.

Fields
 | Name | Description
Public field | Value | The mp_limb_t value.
Top
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_limb_t.Value Field

mp_limb_tValue Field
The mp_limb_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public ulong Value
Public Value As ULong
public:
unsigned long long Value
val mutable Value: uint64

Field Value

Type: UInt64
See Also

Reference

mp_limb_t Structure
Math.Gmp.Native Namespace


mp_ptr Class

mp_ptr Class
Represents a pointer to an array of mp_limb_t values in unmanaged memory,
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativemp_ptr

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class mp_ptr : IEnumerable<mp_limb_t>,
    IEnumerable
Public Class mp_ptr
    Implements IEnumerable(Of mp_limb_t), IEnumerable
public ref class mp_ptr : IEnumerable<mp_limb_t>,
    IEnumerable
type mp_ptr =
    class
        interface IEnumerable<mp_limb_t>
        interface IEnumerable
    end

The mp_ptr type exposes the following members.

Constructors
 | Name | Description
Public method | mp_ptr(Byte) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt16) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt32) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt64) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(mp_base) | Creates new pointer to array of limbs at mp.
Public method | mp_ptr(mp_size_t) | Creates a new array of size limbs in unmanaged memory.
Top
Properties
 | Name | Description
Public property | Item | Gets or sets the value of the limb at index.
Public property | Size | The number of limbs.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetEnumerator | Returns an enumerator that iterates through the array of limbs.
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Returns pointer to limbs in unmanaged memory.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
Remarks

See Also

Reference

Math.Gmp.Native Namespace


mp_ptr Constructor

mp_ptr Constructor
Overload List
 | Name | Description
Public method | mp_ptr(Byte) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt16) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt32) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(UInt64) | Creates a new array of limbs initialized with values in unmanaged memory.
Public method | mp_ptr(mp_base) | Creates new pointer to array of limbs at mp.
Public method | mp_ptr(mp_size_t) | Creates a new array of size limbs in unmanaged memory.
Top
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr Constructor (Byte[])

mp_ptr Constructor (Byte)
Creates a new array of limbs initialized with values in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    byte[] values
)
Public Sub New (
    values As Byte()
)
public:
mp_ptr(
    array<unsigned char>^ values
)
new :
        values : byte[] -> mp_ptr

Parameters

values
Type: SystemByte
The values of the limbs.
Remarks

If there is not enough bytes to fill out the most significant limb, it is padded with zeroes.

When done with the array, you must release the unmanaged memory by calling free.

See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Constructor (UInt16[])

mp_ptr Constructor (UInt16)
Creates a new array of limbs initialized with values in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    ushort[] values
)
Public Sub New (
    values As UShort()
)
public:
mp_ptr(
    array<unsigned short>^ values
)
new :
        values : uint16[] -> mp_ptr

Parameters

values
Type: SystemUInt16
The values of the limbs.
Remarks

If there is not enough 16-bit words to fill out the most significant limb, it is padded with zeroes.

When done with the array, you must release the unmanaged memory by calling free.

See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Constructor (UInt32[])

mp_ptr Constructor (UInt32)
Creates a new array of limbs initialized with values in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    uint[] values
)
Public Sub New (
    values As UInteger()
)
public:
mp_ptr(
    array<unsigned int>^ values
)
new :
        values : uint32[] -> mp_ptr

Parameters

values
Type: SystemUInt32
The values of the limbs.
Remarks

If there is not enough 32-bit words to fill out the most significant limb, it is padded with zeroes.

When done with the array, you must release the unmanaged memory by calling free.

See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Constructor (UInt64[])

mp_ptr Constructor (UInt64)
Creates a new array of limbs initialized with values in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    ulong[] values
)
Public Sub New (
    values As ULong()
)
public:
mp_ptr(
    array<unsigned long long>^ values
)
new :
        values : uint64[] -> mp_ptr

Parameters

values
Type: SystemUInt64
The values of the limbs.
Remarks

If limbs size is 32 bits, the 64-bit values are split into 32-bit limbs.

When done with the array, you must release the unmanaged memory by calling free.

See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Constructor (mp_base)

mp_ptr Constructor (mp_base)
Creates new pointer to array of limbs at mp.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    mp_base mp
)
Public Sub New (
    mp As mp_base
)
public:
mp_ptr(
    mp_base^ mp
)
new :
        mp : mp_base -> mp_ptr

Parameters

mp
Type: Math.Gmp.Nativemp_base
Represents an array of limbs.
See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Constructor (mp_size_t)

mp_ptr Constructor (mp_size_t)
Creates a new array of size limbs in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_ptr(
    mp_size_t size
)
Public Sub New (
    size As mp_size_t
)
public:
mp_ptr(
    mp_size_t size
)
new :
        size : mp_size_t -> mp_ptr

Parameters

size
Type: Math.Gmp.Nativemp_size_t
The number of limbs.
Remarks

When done with the array, you must release the unmanaged memory by calling free.

See Also

Reference

mp_ptr Class
mp_ptr Overload
Math.Gmp.Native Namespace


mp_ptr Properties

mp_ptr Properties

The mp_ptr type exposes the following members.

Properties
 | Name | Description
Public property | Item | Gets or sets the value of the limb at index.
Public property | Size | The number of limbs.
Top
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr.Item Property

mp_ptrItem Property
Gets or sets the value of the limb at index.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_limb_t this[
    int index
] { get; set; }
Public Default Property Item (
    index As Integer
) As mp_limb_t
    Get
    Set
public:
property mp_limb_t default[int index] {
    mp_limb_t get (int index);
    void set (int index, mp_limb_t value);
}
member Item : mp_limb_t with get, set

Parameters

index
Type: SystemInt32
The zero-based index of the limb to get or set.

Return Value

Type: mp_limb_t
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr.Size Property

mp_ptrSize Property
The number of limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_size_t Size { get; }
Public ReadOnly Property Size As mp_size_t
    Get
public:
property mp_size_t Size {
    mp_size_t get ();
}
member Size : mp_size_t with get

Property Value

Type: mp_size_t
Remarks
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr Methods

mp_ptr Methods

The mp_ptr type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetEnumerator | Returns an enumerator that iterates through the array of limbs.
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Returns pointer to limbs in unmanaged memory.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr.GetEnumerator Method

mp_ptrGetEnumerator Method
Returns an enumerator that iterates through the array of limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IEnumerator<mp_limb_t> GetEnumerator()
Public Function GetEnumerator As IEnumerator(Of mp_limb_t)
public:
virtual IEnumerator<mp_limb_t>^ GetEnumerator() sealed
abstract GetEnumerator : unit -> IEnumerator<mp_limb_t>
override GetEnumerator : unit -> IEnumerator<mp_limb_t>

Return Value

Type: IEnumerator mp_limb_t
An enumerator that iterates through the array of limbs.

Implements

IEnumerableTGetEnumerator
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_ptr.ToIntPtr Method

mp_ptrToIntPtr Method
Returns pointer to limbs in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
Returns pointer to limbs in unmanaged memory.
See Also

Reference

mp_ptr Class
Math.Gmp.Native Namespace


mp_size_t Structure

mp_size_t Structure
Represents a count of limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct mp_size_t
Public Structure mp_size_t
public value class mp_size_t
[<SealedAttribute>]
type mp_size_t =  struct end

The mp_size_t type exposes the following members.

Constructors
 | Name | Description
Public method | mp_size_t | Creates a new mp_size_t, and sets its value.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_size_t) | Returns a value indicating whether this instance is equal to a specified mp_size_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_size_t. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int64 to mp_size_t) | Converts an Int64 value to a mp_size_t value.
(UInt32 to mp_size_t) | Converts a UInt32 value to an mp_size_t value.
(UInt64 to mp_size_t) | Converts a UInt64 value to an mp_size_t value.
(mp_size_t to Byte) | Converts an mp_size_t value to a Byte value.
(mp_size_t to SByte) | Converts an mp_size_t value to an SByte value.
(mp_size_t to UInt16) | Converts an mp_size_t value to a UInt16 value.
(mp_size_t to Int16) | Converts an mp_size_t value to an Int16 value.
(mp_size_t to UInt32) | Converts an mp_size_t value to a UInt32 value.
(mp_size_t to UInt64) | Converts an mp_size_t value to a UInt64 value.
(Byte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(Int16 to mp_size_t) | Converts an Int16 value to an mp_size_t value.
(Int32 to mp_size_t) | Converts an Int32 value to an mp_size_t value.
(SByte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(UInt16 to mp_size_t) | Converts a UInt16 value to an mp_size_t value.
(mp_size_t to Int32) | Converts an mp_size_t value to an Int32 value.
(mp_size_t to Int64) | Converts an mp_size_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | The mp_size_t value.
Top
Remarks

Counts of limbs of a multi-precision number represented in the C type mp_size_t. Currently this is normally a long, but on some systems it’s an int for efficiency, and on some systems it will be long long in the future.

In .Net, this is a 32-bit integer.

See Also

Reference

Math.Gmp.Native Namespace
mp_limb_t
mpf_t
mpq_t
mpz_t


mp_size_t Constructor

mp_size_t Constructor
Creates a new mp_size_t, and sets its value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mp_size_t(
    int value
)
Public Sub New (
    value As Integer
)
public:
mp_size_t(
    int value
)
new :
        value : int -> mp_size_t

Parameters

value
Type: SystemInt32
The value of the new mp_size_t.
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Methods

mp_size_t Methods

The mp_size_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_size_t) | Returns a value indicating whether this instance is equal to a specified mp_size_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the mp_size_t. (Overrides ValueTypeToString.)
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t.Equals Method

mp_size_tEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(mp_size_t) | Returns a value indicating whether this instance is equal to a specified mp_size_t value.
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t.Equals Method (Object)

mp_size_tEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of mp_size_t and equals the value of this instance; otherwise, False.
See Also

Reference

mp_size_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_size_t.Equals Method (mp_size_t)

mp_size_tEquals Method (mp_size_t)
Returns a value indicating whether this instance is equal to a specified mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    mp_size_t other
)
Public Function Equals (
    other As mp_size_t
) As Boolean
public:
bool Equals(
    mp_size_t other
)
member Equals :
        other : mp_size_t -> bool

Parameters

other
Type: Math.Gmp.Nativemp_size_t
A mp_size_t value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

mp_size_t Structure
Equals Overload
Math.Gmp.Native Namespace


mp_size_t.GetHashCode Method

mp_size_tGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t.ToString Method

mp_size_tToString Method
Gets the string representation of the mp_size_t.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the mp_size_t.
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Operators and Type Conversions

mp_size_t Operators and Type Conversions

The mp_size_t type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int64 to mp_size_t) | Converts an Int64 value to a mp_size_t value.
(UInt32 to mp_size_t) | Converts a UInt32 value to an mp_size_t value.
(UInt64 to mp_size_t) | Converts a UInt64 value to an mp_size_t value.
(mp_size_t to Byte) | Converts an mp_size_t value to a Byte value.
(mp_size_t to SByte) | Converts an mp_size_t value to an SByte value.
(mp_size_t to UInt16) | Converts an mp_size_t value to a UInt16 value.
(mp_size_t to Int16) | Converts an mp_size_t value to an Int16 value.
(mp_size_t to UInt32) | Converts an mp_size_t value to a UInt32 value.
(mp_size_t to UInt64) | Converts an mp_size_t value to a UInt64 value.
(Byte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(Int16 to mp_size_t) | Converts an Int16 value to an mp_size_t value.
(Int32 to mp_size_t) | Converts an Int32 value to an mp_size_t value.
(SByte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(UInt16 to mp_size_t) | Converts a UInt16 value to an mp_size_t value.
(mp_size_t to Int32) | Converts an mp_size_t value to an Int32 value.
(mp_size_t to Int64) | Converts an mp_size_t value to an Int64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t.Equality Operator

mp_size_tEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    mp_size_t value1,
    mp_size_t value2
)
Public Shared Operator = (
    value1 As mp_size_t,
    value2 As mp_size_t
) As Boolean
public:
static bool operator ==(
    mp_size_t value1,
    mp_size_t value2
)
static let inline (=)
        value1 : mp_size_t *
        value2 : mp_size_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_size_t
A mp_size_t value.
value2
Type: Math.Gmp.Nativemp_size_t
A mp_size_t value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion Operators

mp_size_t Conversion Operators
Overload List
Name | Description
(Int64 to mp_size_t) | Converts an Int64 value to a mp_size_t value.
(UInt32 to mp_size_t) | Converts a UInt32 value to an mp_size_t value.
(UInt64 to mp_size_t) | Converts a UInt64 value to an mp_size_t value.
(mp_size_t to Byte) | Converts an mp_size_t value to a Byte value.
(mp_size_t to SByte) | Converts an mp_size_t value to an SByte value.
(mp_size_t to UInt16) | Converts an mp_size_t value to a UInt16 value.
(mp_size_t to Int16) | Converts an mp_size_t value to an Int16 value.
(mp_size_t to UInt32) | Converts an mp_size_t value to a UInt32 value.
(mp_size_t to UInt64) | Converts an mp_size_t value to a UInt64 value.
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (Int64 to mp_size_t)

mp_size_t Conversion (Int64 to mp_size_t)
Converts an Int64 value to a mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_size_t (
    long value
)
Public Shared Narrowing Operator CType (
    value As Long
) As mp_size_t
static explicit operator mp_size_t (
    long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt64
An Int64 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (UInt32 to mp_size_t)

mp_size_t Conversion (UInt32 to mp_size_t)
Converts a UInt32 value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_size_t (
    uint value
)
Public Shared Narrowing Operator CType (
    value As UInteger
) As mp_size_t
static explicit operator mp_size_t (
    unsigned int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt32
A UInt32 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (UInt64 to mp_size_t)

mp_size_t Conversion (UInt64 to mp_size_t)
Converts a UInt64 value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator mp_size_t (
    ulong value
)
Public Shared Narrowing Operator CType (
    value As ULong
) As mp_size_t
static explicit operator mp_size_t (
    unsigned long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt64
A UInt64 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to Byte)

mp_size_t Conversion (mp_size_t to Byte)
Converts an mp_size_t value to a Byte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator byte (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As Byte
static explicit operator unsigned char (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: Byte
A Byte value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to SByte)

mp_size_t Conversion (mp_size_t to SByte)
Converts an mp_size_t value to an SByte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator sbyte (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As SByte
static explicit operator signed char (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: SByte
An SByte value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to UInt16)

mp_size_t Conversion (mp_size_t to UInt16)
Converts an mp_size_t value to a UInt16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ushort (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As UShort
static explicit operator unsigned short (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: UInt16
A UInt16 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to Int16)

mp_size_t Conversion (mp_size_t to Int16)
Converts an mp_size_t value to an Int16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator short (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As Short
static explicit operator short (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: Int16
An Int16 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to UInt32)

mp_size_t Conversion (mp_size_t to UInt32)
Converts an mp_size_t value to a UInt32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator uint (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As UInteger
static explicit operator unsigned int (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: UInt32
A UInt32 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Explicit Conversion (mp_size_t to UInt64)

mp_size_t Conversion (mp_size_t to UInt64)
Converts an mp_size_t value to a UInt64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ulong (
    mp_size_t value
)
Public Shared Narrowing Operator CType (
    value As mp_size_t
) As ULong
static explicit operator unsigned long long (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: UInt64
A UInt64 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion Operators

mp_size_t Conversion Operators
Overload List
Name | Description
(Byte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(Int16 to mp_size_t) | Converts an Int16 value to an mp_size_t value.
(Int32 to mp_size_t) | Converts an Int32 value to an mp_size_t value.
(SByte to mp_size_t) | Converts a Byte value to an mp_size_t value.
(UInt16 to mp_size_t) | Converts a UInt16 value to an mp_size_t value.
(mp_size_t to Int32) | Converts an mp_size_t value to an Int32 value.
(mp_size_t to Int64) | Converts an mp_size_t value to an Int64 value.
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (Byte to mp_size_t)

mp_size_t Conversion (Byte to mp_size_t)
Converts a Byte value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_size_t (
    byte value
)
Public Shared Widening Operator CType (
    value As Byte
) As mp_size_t
static implicit operator mp_size_t (
    unsigned char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemByte
A Byte value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (Int16 to mp_size_t)

mp_size_t Conversion (Int16 to mp_size_t)
Converts an Int16 value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_size_t (
    short value
)
Public Shared Widening Operator CType (
    value As Short
) As mp_size_t
static implicit operator mp_size_t (
    short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt16
An Int16 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (Int32 to mp_size_t)

mp_size_t Conversion (Int32 to mp_size_t)
Converts an Int32 value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_size_t (
    int value
)
Public Shared Widening Operator CType (
    value As Integer
) As mp_size_t
static implicit operator mp_size_t (
    int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt32
An Int32 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (SByte to mp_size_t)

mp_size_t Conversion (SByte to mp_size_t)
Converts a Byte value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_size_t (
    sbyte value
)
Public Shared Widening Operator CType (
    value As SByte
) As mp_size_t
static implicit operator mp_size_t (
    signed char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemSByte
A Byte value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (UInt16 to mp_size_t)

mp_size_t Conversion (UInt16 to mp_size_t)
Converts a UInt16 value to an mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mp_size_t (
    ushort value
)
Public Shared Widening Operator CType (
    value As UShort
) As mp_size_t
static implicit operator mp_size_t (
    unsigned short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt16
A UInt16 value.

Return Value

Type: mp_size_t
An mp_size_t value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (mp_size_t to Int32)

mp_size_t Conversion (mp_size_t to Int32)
Converts an mp_size_t value to an Int32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator int (
    mp_size_t value
)
Public Shared Widening Operator CType (
    value As mp_size_t
) As Integer
static implicit operator int (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: Int32
An Int32 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t Implicit Conversion (mp_size_t to Int64)

mp_size_t Conversion (mp_size_t to Int64)
Converts an mp_size_t value to an Int64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator long (
    mp_size_t value
)
Public Shared Widening Operator CType (
    value As mp_size_t
) As Long
static implicit operator long long (
    mp_size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativemp_size_t
An mp_size_t value.

Return Value

Type: Int64
An Int64 value.
See Also

Reference

mp_size_t Structure
Overload
Math.Gmp.Native Namespace


mp_size_t.Inequality Operator

mp_size_tInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    mp_size_t value1,
    mp_size_t value2
)
Public Shared Operator <> (
    value1 As mp_size_t,
    value2 As mp_size_t
) As Boolean
public:
static bool operator !=(
    mp_size_t value1,
    mp_size_t value2
)
static let inline (<>)
        value1 : mp_size_t *
        value2 : mp_size_t  : bool

Parameters

value1
Type: Math.Gmp.Nativemp_size_t
A mp_size_t value.
value2
Type: Math.Gmp.Nativemp_size_t
A mp_size_t value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t Fields

mp_size_t Fields

The mp_size_t type exposes the following members.

Fields
 | Name | Description
Public field | Value | The mp_size_t value.
Top
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mp_size_t.Value Field

mp_size_tValue Field
The mp_size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public int Value
Public Value As Integer
public:
int Value
val mutable Value: int

Field Value

Type: Int32
See Also

Reference

mp_size_t Structure
Math.Gmp.Native Namespace


mpf_t Class

mpf_t Class
Represents a multiple precision floating-point number.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativemp_base
Math.Gmp.Nativempf_t

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class mpf_t : mp_base
Public Class mpf_t
    Inherits mp_base
public ref class mpf_t : public mp_base
type mpf_t =
    class
        inherit mp_base
    end

The mpf_t type exposes the following members.

Constructors
 | Name | Description
Public method | mpf_t | Initializes a new instance of the mpf_t class
Top
Properties
 | Name | Description
Public property | _mp_d | A pointer to an array of limbs which is the magnitude. (Inherited from mp_base.)
Public property | _mp_d_intptr | Gets or sets the pointer to the significand array of limbs of the floating-point number. (Overrides mp_base_mp_d_intptr.)
Public property | _mp_exp | The exponent, in limbs, determining the location of the implied radix point.
Public property | _mp_prec | The precision of the mantissa, in limbs.
Public property | _mp_size | The number of limbs currently in use, or the negative of that when representing a negative value. (Overrides mp_base_mp_size.)
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision floating-point number.
Public method | ToString | Return the string representation of the float. (Overrides ObjectToString.)
Top
Operators
Name | Description
(String to mpf_t) | Converts a string value to an mpf_t value.
Top
Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory. (Inherited from mp_base.)
Top
Remarks

The floating point functions accept and return exponents in the C type mp_exp_t. Currently this is usually a long, but on some systems it’s an int for efficiency.

In .NET, this is a 32-bit integer.

See Also

Reference

Math.Gmp.Native Namespace
mp_exp_t
mp_limb_t
mpq_t
mpz_t


mpf_t Constructor

mpf_t Constructor
Initializes a new instance of the mpf_t class

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mpf_t()
Public Sub New
public:
mpf_t()
new : unit -> mpf_t
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t Properties

mpf_t Properties

The mpf_t type exposes the following members.

Properties
 | Name | Description
Public property | _mp_d | A pointer to an array of limbs which is the magnitude. (Inherited from mp_base.)
Public property | _mp_d_intptr | Gets or sets the pointer to the significand array of limbs of the floating-point number. (Overrides mp_base_mp_d_intptr.)
Public property | _mp_exp | The exponent, in limbs, determining the location of the implied radix point.
Public property | _mp_prec | The precision of the mantissa, in limbs.
Public property | _mp_size | The number of limbs currently in use, or the negative of that when representing a negative value. (Overrides mp_base_mp_size.)
Top
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t._mp_d_intptr Property

mpf_t_mp_d_intptr Property
Gets or sets the pointer to the significand array of limbs of the floating-point number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override IntPtr _mp_d_intptr { get; set; }
Public Overrides Property _mp_d_intptr As IntPtr
    Get
    Set
public:
virtual property IntPtr _mp_d_intptr {
    IntPtr get () override;
    void set (IntPtr value) override;
}
abstract _mp_d_intptr : IntPtr with get, set
override _mp_d_intptr : IntPtr with get, set

Property Value

Type: IntPtr
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t._mp_exp Property

mpf_t_mp_exp Property
The exponent, in limbs, determining the location of the implied radix point.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public int _mp_exp { get; }
Public ReadOnly Property _mp_exp As Integer
    Get
public:
property int _mp_exp {
    int get ();
}
member _mp_exp : int with get

Property Value

Type: Int32
Remarks

Zero means the radix point is just above the most significant limb. Positive values mean a radix point offset towards the lower limbs and hence a value ≥ 1, as for example in the diagram above. Negative exponents mean a radix point further above the highest limb.

Naturally the exponent can be any value, it doesn’t have to fall within the limbs as the diagram shows, it can be a long way above or a long way below. Limbs other than those included in the {mp_base._mp_d, _mp_size} data are treated as zero.

See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t._mp_prec Property

mpf_t_mp_prec Property
The precision of the mantissa, in limbs.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public int _mp_prec { get; }
Public ReadOnly Property _mp_prec As Integer
    Get
public:
property int _mp_prec {
    int get ();
}
member _mp_prec : int with get

Property Value

Type: Int32
Remarks

In any calculation the aim is to produce _mp_prec limbs of result (the most significant being non-zero).

See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t._mp_size Property

mpf_t_mp_size Property
The number of limbs currently in use, or the negative of that when representing a negative value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override mp_size_t _mp_size { get; }
Public Overrides ReadOnly Property _mp_size As mp_size_t
    Get
public:
virtual property mp_size_t _mp_size {
    mp_size_t get () override;
}
abstract _mp_size : mp_size_t with get
override _mp_size : mp_size_t with get

Property Value

Type: mp_size_t
Remarks

Zero is represented by _mp_size and _mp_exp both set to zero, and in that case the mp_base._mp_d data is unused. (In the future _mp_exp might be undefined when representing zero.)

See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t Methods

mpf_t Methods

The mpf_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision floating-point number.
Public method | ToString | Return the string representation of the float. (Overrides ObjectToString.)
Top
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t.ToIntPtr Method

mpf_tToIntPtr Method
Gets the unmanaged memory pointer of the multiple precision floating-point number.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
The unmanaged memory pointer of the multiple precision floating-point number.
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t.ToString Method

mpf_tToString Method
Return the string representation of the float.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the float.
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t Type Conversions

mpf_t Type Conversions

The mpf_t type exposes the following members.

Operators
Name | Description
(String to mpf_t) | Converts a string value to an mpf_t value.
Top
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t Implicit Conversion (String to mpf_t)

mpf_t Conversion (String to mpf_t)
Converts a string value to an mpf_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mpf_t (
    string value
)
Public Shared Widening Operator CType (
    value As String
) As mpf_t
static implicit operator mpf_t^ (
    String^ value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemString
A string value.

Return Value

Type: mpf_t
An mpf_t value.
Remarks

Base is assumed to be 10 unless the first character of the string is B followed by the base 2 to 62 or -62 to -2 followed by a space and then the floating-point number. Negative values are used to specify that the exponent is in decimal.

See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpf_t Fields

mpf_t Fields

The mpf_t type exposes the following members.

Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory. (Inherited from mp_base.)
Top
See Also

Reference

mpf_t Class
Math.Gmp.Native Namespace


mpq_t Class

mpq_t Class
Represents a multiple precision rational number.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativempq_t

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class mpq_t
Public Class mpq_t
public ref class mpq_t
type mpq_t =  class end

The mpq_t type exposes the following members.

Constructors
 | Name | Description
Public method | mpq_t | Creates a new multiple precision rational.
Top
Properties
 | Name | Description
Public property | _mp_den | Get the denominator integer of the rational.
Public property | _mp_num | Get the numerator integer of the rational.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision rational.
Public method | ToString | Return the string representation of the rational. (Overrides ObjectToString.)
Top
Operators
Name | Description
(String to mpq_t) | Converts a string value to an mpq_t value.
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace
mpf_t
mpz_t


mpq_t Constructor

mpq_t Constructor
Creates a new multiple precision rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mpq_t()
Public Sub New
public:
mpq_t()
new : unit -> mpq_t
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t Properties

mpq_t Properties

The mpq_t type exposes the following members.

Properties
 | Name | Description
Public property | _mp_den | Get the denominator integer of the rational.
Public property | _mp_num | Get the numerator integer of the rational.
Top
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t._mp_den Property

mpq_t_mp_den Property
Get the denominator integer of the rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mpz_t _mp_den { get; }
Public ReadOnly Property _mp_den As mpz_t
    Get
public:
property mpz_t^ _mp_den {
    mpz_t^ get ();
}
member _mp_den : mpz_t with get

Return Value

Type: mpz_t
The denominator integer of the rational.
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t._mp_num Property

mpq_t_mp_num Property
Get the numerator integer of the rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mpz_t _mp_num { get; }
Public ReadOnly Property _mp_num As mpz_t
    Get
public:
property mpz_t^ _mp_num {
    mpz_t^ get ();
}
member _mp_num : mpz_t with get

Return Value

Type: mpz_t
The numerator integer of the rational.
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t Methods

mpq_t Methods

The mpq_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision rational.
Public method | ToString | Return the string representation of the rational. (Overrides ObjectToString.)
Top
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t.ToIntPtr Method

mpq_tToIntPtr Method
Gets the unmanaged memory pointer of the multiple precision rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
The unmanaged memory pointer of the multiple precision rational.
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t.ToString Method

mpq_tToString Method
Return the string representation of the rational.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the rational.
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t Type Conversions

mpq_t Type Conversions

The mpq_t type exposes the following members.

Operators
Name | Description
(String to mpq_t) | Converts a string value to an mpq_t value.
Top
See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpq_t Implicit Conversion (String to mpq_t)

mpq_t Conversion (String to mpq_t)
Converts a string value to an mpq_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mpq_t (
    string value
)
Public Shared Widening Operator CType (
    value As String
) As mpq_t
static implicit operator mpq_t^ (
    String^ value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemString
A string value.

Return Value

Type: mpq_t
An mpq_t value.
Remarks

The leading characters are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or decimal otherwise. Note that this is done separately for the numerator and denominator, so for instance 0xEF/100 is 239/100, whereas 0xEF/0x100 is 239/256.

See Also

Reference

mpq_t Class
Math.Gmp.Native Namespace


mpz_t Class

mpz_t Class
Represents a multiple precision integer.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativemp_base
Math.Gmp.Nativempz_t

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class mpz_t : mp_base
Public Class mpz_t
    Inherits mp_base
public ref class mpz_t : public mp_base
type mpz_t =
    class
        inherit mp_base
    end

The mpz_t type exposes the following members.

Constructors
 | Name | Description
Public method | mpz_t | Creates a new multiple precision integer.
Top
Properties
 | Name | Description
Public property | _mp_alloc | The number of limbs currently allocated at mp_base._mp_d.
Public property | _mp_d | A pointer to an array of limbs which is the magnitude. (Inherited from mp_base.)
Public property | _mp_d_intptr | Gets or sets the pointer to the array of limbs of the integer. (Overrides mp_base_mp_d_intptr.)
Public property | _mp_size | The number of limbs, or the negative of that when representing a negative integer. (Overrides mp_base_mp_size.)
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision integer.
Public method | ToString | Return the string representation of the integer. (Overrides ObjectToString.)
Top
Operators
Name | Description
(String to mpz_t) | Converts a string value to an mpz_t value.
Top
Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory. (Inherited from mp_base.)
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace
mp_limb_t
mpf_t
mpq_t


mpz_t Constructor

mpz_t Constructor
Creates a new multiple precision integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public mpz_t()
Public Sub New
public:
mpz_t()
new : unit -> mpz_t
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t Properties

mpz_t Properties

The mpz_t type exposes the following members.

Properties
 | Name | Description
Public property | _mp_alloc | The number of limbs currently allocated at mp_base._mp_d.
Public property | _mp_d | A pointer to an array of limbs which is the magnitude. (Inherited from mp_base.)
Public property | _mp_d_intptr | Gets or sets the pointer to the array of limbs of the integer. (Overrides mp_base_mp_d_intptr.)
Public property | _mp_size | The number of limbs, or the negative of that when representing a negative integer. (Overrides mp_base_mp_size.)
Top
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t._mp_alloc Property

mpz_t_mp_alloc Property
The number of limbs currently allocated at mp_base._mp_d.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public int _mp_alloc { get; }
Public ReadOnly Property _mp_alloc As Integer
    Get
public:
property int _mp_alloc {
    int get ();
}
member _mp_alloc : int with get

Property Value

Type: Int32
Remarks

mpz_t._mp_alloc is the number of limbs currently allocated at mp_base._mp_d, and naturally mpz_t._mp_alloc >= ABS(mpz_t._mp_size). When an mpz routine is about to (or might be about to) increase mpz_t._mp_size, it checks mpz_t._mp_alloc to see whether there’s enough space, and reallocates if not.

See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t._mp_d_intptr Property

mpz_t_mp_d_intptr Property
Gets or sets the pointer to the array of limbs of the integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override IntPtr _mp_d_intptr { get; set; }
Public Overrides Property _mp_d_intptr As IntPtr
    Get
    Set
public:
virtual property IntPtr _mp_d_intptr {
    IntPtr get () override;
    void set (IntPtr value) override;
}
abstract _mp_d_intptr : IntPtr with get, set
override _mp_d_intptr : IntPtr with get, set

Property Value

Type: IntPtr
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t._mp_size Property

mpz_t_mp_size Property
The number of limbs, or the negative of that when representing a negative integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override mp_size_t _mp_size { get; set; }
Public Overrides Property _mp_size As mp_size_t
    Get
    Set
public:
virtual property mp_size_t _mp_size {
    mp_size_t get () override;
    void set (mp_size_t value) override;
}
abstract _mp_size : mp_size_t with get, set
override _mp_size : mp_size_t with get, set

Property Value

Type: mp_size_t
Remarks

The number of limbs, or the negative of that when representing a negative integer. Zero is represented by mp_base._mp_size set to zero, in which case the mp_base._mp_d data is unused.

See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t Methods

mpz_t Methods

The mpz_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToIntPtr | Gets the unmanaged memory pointer of the multiple precision integer.
Public method | ToString | Return the string representation of the integer. (Overrides ObjectToString.)
Top
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t.ToIntPtr Method

mpz_tToIntPtr Method
Gets the unmanaged memory pointer of the multiple precision integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
The unmanaged memory pointer of the multiple precision integer.
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t.ToString Method

mpz_tToString Method
Return the string representation of the integer.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the integer.
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t Type Conversions

mpz_t Type Conversions

The mpz_t type exposes the following members.

Operators
Name | Description
(String to mpz_t) | Converts a string value to an mpz_t value.
Top
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t Implicit Conversion (String to mpz_t)

mpz_t Conversion (String to mpz_t)
Converts a string value to an mpz_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator mpz_t (
    string value
)
Public Shared Widening Operator CType (
    value As String
) As mpz_t
static implicit operator mpz_t^ (
    String^ value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemString
A string value.

Return Value

Type: mpz_t
An mpz_t value.
Remarks

The leading characters are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or decimal otherwise.

See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


mpz_t Fields

mpz_t Fields

The mpz_t type exposes the following members.

Fields
 | Name | Description
Public field | Pointer | Pointer to limbs in unmanaged memory. (Inherited from mp_base.)
Top
See Also

Reference

mpz_t Class
Math.Gmp.Native Namespace


ptr(T) Class

ptrT Class
Represents a pointer to a value of type T.
Inheritance Hierarchy
SystemObject
Math.Gmp.NativeptrT

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class ptr<T>
where T : struct, new()

Public Class ptr(Of T As {Structure, New})
generic<typename T>
where T : value class, gcnew()
public ref class ptr
type ptr<'T when 'T : struct, new()> =  class end

Type Parameters

T
A value type.

The ptrT type exposes the following members.

Constructors
 | Name | Description
Public method | ptrT | Creates a new pointer with default value.
Public method | ptrT(T) | Creates a new pointer with Value set to value.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
Fields
 | Name | Description
Public field | Value | The value that is "pointed to".
Top
Remarks

Mimics the C address-of (&) construct to pass the address of a value type variable to a function of the GMP library.

Note that this is only for value types. Strings and arrays have their own "pointer" types defined with names ending in _ptr.

See Also

Reference

Math.Gmp.Native Namespace


ptr(T) Constructor

ptrT Constructor
Overload List
 | Name | Description
Public method | ptrT | Creates a new pointer with default value.
Public method | ptrT(T) | Creates a new pointer with Value set to value.
Top
See Also

Reference

ptrT Class
Math.Gmp.Native Namespace


ptr(T) Constructor

ptrT Constructor
Creates a new pointer with default value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public ptr()
Public Sub New
public:
ptr()
new : unit -> ptr
See Also

Reference

ptrT Class
ptrT Overload
Math.Gmp.Native Namespace


ptr(T) Constructor (T)

ptrT Constructor (T)
Creates a new pointer with Value set to value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public ptr(
    T value
)
Public Sub New (
    value As T
)
public:
ptr(
    T value
)
new :
        value : 'T -> ptr

Parameters

value
Type: T
The initial value.
See Also

Reference

ptrT Class
ptrT Overload
Math.Gmp.Native Namespace


ptr(T) Methods

ptrT Methods

The ptrT generic type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

ptrT Class
Math.Gmp.Native Namespace


ptr(T) Fields

ptrT Fields

The ptrT generic type exposes the following members.

Fields
 | Name | Description
Public field | Value | The value that is "pointed to".
Top
See Also

Reference

ptrT Class
Math.Gmp.Native Namespace


ptr(T).Value Field

ptrTValue Field
The value that is "pointed to".

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public T Value
Public Value As T
public:
T Value
val mutable Value: 'T

Field Value

Type: T
See Also

Reference

ptrT Class
Math.Gmp.Native Namespace


reallocate_function Delegate

reallocate_function Delegate
Resize a previously allocated block ptr of old_size bytes to be new_size bytes.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public delegate void_ptr reallocate_function(
    void_ptr ptr,
    size_t old_size,
    size_t new_size
)
Public Delegate Function reallocate_function (
    ptr As void_ptr,
    old_size As size_t,
    new_size As size_t
) As void_ptr
public delegate void_ptr reallocate_function(
    void_ptr ptr,
    size_t old_size,
    size_t new_size
)
type reallocate_function =
    delegate of
        ptr : void_ptr *
        old_size : size_t *
        new_size : size_t -> void_ptr

Parameters

ptr
Type: Math.Gmp.Nativevoid_ptr
Pointer to previously allocated block.
old_size
Type: Math.Gmp.Nativesize_t
Number of bytes of previously allocated block.
new_size
Type: Math.Gmp.Nativesize_t
New number of bytes of previously allocated block.

Return Value

Type: void_ptr
A previously allocated block ptr of old_size bytes to be new_size bytes.
See Also

Reference

Math.Gmp.Native Namespace


size_t Structure

size_t Structure
Represents a count of characters or bytes.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct size_t
Public Structure size_t
public value class size_t
[<SealedAttribute>]
type size_t =  struct end

The size_t type exposes the following members.

Constructors
 | Name | Description
Public method | size_t | Creates a new size_t, and sets its value.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(size_t) | Returns a value indicating whether this instance is equal to a specified size_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the size_t. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to size_t) | Converts an Int16 value to a size_t value.
(Int32 to size_t) | Converts an Int32 value to a size_t value.
(Int64 to size_t) | Converts an Int64 value to a size_t value.
(SByte to size_t) | Converts a SByte value to a size_t value.
(size_t to Byte) | Converts a size_t value to a Byte value.
(size_t to SByte) | Converts a size_t value to an SByte value.
(size_t to UInt16) | Converts a size_t value to a UInt16 value.
(size_t to Int16) | Converts a size_t value to an Int16 value.
(size_t to UInt32) | Converts a size_t value to a UInt32 value.
(size_t to Int32) | Converts a size_t value to an Int32 value.
(size_t to Int64) | Converts a size_t value to an Int64 value.
(Byte to size_t) | Converts a Byte value to a size_t value.
(UInt16 to size_t) | Converts a UInt16 value to a size_t value.
(UInt32 to size_t) | Converts a UInt32 value to a size_t value.
(UInt64 to size_t) | Converts a UInt64 value to a size_t value.
(size_t to UInt64) | Converts a size_t value to a UInt64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
 | Name | Description
Public field | Value | The size_t value.
Top
Remarks

In .NET, this is an unsigned 64-bit integer.

See Also

Reference

Math.Gmp.Native Namespace


size_t Constructor

size_t Constructor
Creates a new size_t, and sets its value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public size_t(
    ulong value
)
Public Sub New (
    value As ULong
)
public:
size_t(
    unsigned long long value
)
new :
        value : uint64 -> size_t

Parameters

value
Type: SystemUInt64
The value of the new size_t.
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Methods

size_t Methods

The size_t type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(size_t) | Returns a value indicating whether this instance is equal to a specified size_t value.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToString | Gets the string representation of the size_t. (Overrides ValueTypeToString.)
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t.Equals Method

size_tEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(size_t) | Returns a value indicating whether this instance is equal to a specified size_t value.
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t.Equals Method (Object)

size_tEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of size_t and equals the value of this instance; otherwise, False.
See Also

Reference

size_t Structure
Equals Overload
Math.Gmp.Native Namespace


size_t.Equals Method (size_t)

size_tEquals Method (size_t)
Returns a value indicating whether this instance is equal to a specified size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    size_t other
)
Public Function Equals (
    other As size_t
) As Boolean
public:
bool Equals(
    size_t other
)
member Equals :
        other : size_t -> bool

Parameters

other
Type: Math.Gmp.Nativesize_t
A size_t value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

size_t Structure
Equals Overload
Math.Gmp.Native Namespace


size_t.GetHashCode Method

size_tGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t.ToString Method

size_tToString Method
Gets the string representation of the size_t.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override
abstract ToString : unit -> string
override ToString : unit -> string

Return Value

Type: String
The string representation of the size_t.
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Operators and Type Conversions

size_t Operators and Type Conversions

The size_t type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
(Int16 to size_t) | Converts an Int16 value to a size_t value.
(Int32 to size_t) | Converts an Int32 value to a size_t value.
(Int64 to size_t) | Converts an Int64 value to a size_t value.
(SByte to size_t) | Converts a SByte value to a size_t value.
(size_t to Byte) | Converts a size_t value to a Byte value.
(size_t to SByte) | Converts a size_t value to an SByte value.
(size_t to UInt16) | Converts a size_t value to a UInt16 value.
(size_t to Int16) | Converts a size_t value to an Int16 value.
(size_t to UInt32) | Converts a size_t value to a UInt32 value.
(size_t to Int32) | Converts a size_t value to an Int32 value.
(size_t to Int64) | Converts a size_t value to an Int64 value.
(Byte to size_t) | Converts a Byte value to a size_t value.
(UInt16 to size_t) | Converts a UInt16 value to a size_t value.
(UInt32 to size_t) | Converts a UInt32 value to a size_t value.
(UInt64 to size_t) | Converts a UInt64 value to a size_t value.
(size_t to UInt64) | Converts a size_t value to a UInt64 value.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t.Equality Operator

size_tEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    size_t value1,
    size_t value2
)
Public Shared Operator = (
    value1 As size_t,
    value2 As size_t
) As Boolean
public:
static bool operator ==(
    size_t value1,
    size_t value2
)
static let inline (=)
        value1 : size_t *
        value2 : size_t  : bool

Parameters

value1
Type: Math.Gmp.Nativesize_t
A size_t value.
value2
Type: Math.Gmp.Nativesize_t
A size_t value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Explicit Conversion Operators

size_t Conversion Operators
Overload List
Name | Description
(Int16 to size_t) | Converts an Int16 value to a size_t value.
(Int32 to size_t) | Converts an Int32 value to a size_t value.
(Int64 to size_t) | Converts an Int64 value to a size_t value.
(SByte to size_t) | Converts a SByte value to a size_t value.
(size_t to Byte) | Converts a size_t value to a Byte value.
(size_t to SByte) | Converts a size_t value to an SByte value.
(size_t to UInt16) | Converts a size_t value to a UInt16 value.
(size_t to Int16) | Converts a size_t value to an Int16 value.
(size_t to UInt32) | Converts a size_t value to a UInt32 value.
(size_t to Int32) | Converts a size_t value to an Int32 value.
(size_t to Int64) | Converts a size_t value to an Int64 value.
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Explicit Conversion (Int16 to size_t)

size_t Conversion (Int16 to size_t)
Converts an Int16 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator size_t (
    short value
)
Public Shared Narrowing Operator CType (
    value As Short
) As size_t
static explicit operator size_t (
    short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt16
An Int16 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (Int32 to size_t)

size_t Conversion (Int32 to size_t)
Converts an Int32 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator size_t (
    int value
)
Public Shared Narrowing Operator CType (
    value As Integer
) As size_t
static explicit operator size_t (
    int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt32
An Int32 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (Int64 to size_t)

size_t Conversion (Int64 to size_t)
Converts an Int64 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator size_t (
    long value
)
Public Shared Narrowing Operator CType (
    value As Long
) As size_t
static explicit operator size_t (
    long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemInt64
An Int64 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (SByte to size_t)

size_t Conversion (SByte to size_t)
Converts a SByte value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator size_t (
    sbyte value
)
Public Shared Narrowing Operator CType (
    value As SByte
) As size_t
static explicit operator size_t (
    signed char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemSByte
A SByte value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to Byte)

size_t Conversion (size_t to Byte)
Converts a size_t value to a Byte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator byte (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As Byte
static explicit operator unsigned char (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: Byte
A Byte value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to SByte)

size_t Conversion (size_t to SByte)
Converts a size_t value to an SByte value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator sbyte (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As SByte
static explicit operator signed char (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: SByte
An SByte value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to UInt16)

size_t Conversion (size_t to UInt16)
Converts a size_t value to a UInt16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator ushort (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As UShort
static explicit operator unsigned short (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: UInt16
A UInt16 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to Int16)

size_t Conversion (size_t to Int16)
Converts a size_t value to an Int16 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator short (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As Short
static explicit operator short (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: Int16
An Int16 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to UInt32)

size_t Conversion (size_t to UInt32)
Converts a size_t value to a UInt32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator uint (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As UInteger
static explicit operator unsigned int (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: UInt32
A UInt32 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to Int32)

size_t Conversion (size_t to Int32)
Converts a size_t value to an Int32 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator int (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As Integer
static explicit operator int (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: Int32
An Int32 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Explicit Conversion (size_t to Int64)

size_t Conversion (size_t to Int64)
Converts a size_t value to an Int64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static explicit operator long (
    size_t value
)
Public Shared Narrowing Operator CType (
    value As size_t
) As Long
static explicit operator long long (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: Int64
An Int64 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Implicit Conversion Operators

size_t Conversion Operators
Overload List
Name | Description
(Byte to size_t) | Converts a Byte value to a size_t value.
(UInt16 to size_t) | Converts a UInt16 value to a size_t value.
(UInt32 to size_t) | Converts a UInt32 value to a size_t value.
(UInt64 to size_t) | Converts a UInt64 value to a size_t value.
(size_t to UInt64) | Converts a size_t value to a UInt64 value.
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Implicit Conversion (Byte to size_t)

size_t Conversion (Byte to size_t)
Converts a Byte value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator size_t (
    byte value
)
Public Shared Widening Operator CType (
    value As Byte
) As size_t
static implicit operator size_t (
    unsigned char value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemByte
A Byte value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Implicit Conversion (UInt16 to size_t)

size_t Conversion (UInt16 to size_t)
Converts a UInt16 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator size_t (
    ushort value
)
Public Shared Widening Operator CType (
    value As UShort
) As size_t
static implicit operator size_t (
    unsigned short value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt16
A UInt16 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Implicit Conversion (UInt32 to size_t)

size_t Conversion (UInt32 to size_t)
Converts a UInt32 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator size_t (
    uint value
)
Public Shared Widening Operator CType (
    value As UInteger
) As size_t
static implicit operator size_t (
    unsigned int value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt32
A UInt32 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Implicit Conversion (UInt64 to size_t)

size_t Conversion (UInt64 to size_t)
Converts a UInt64 value to a size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator size_t (
    ulong value
)
Public Shared Widening Operator CType (
    value As ULong
) As size_t
static implicit operator size_t (
    unsigned long long value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: SystemUInt64
A UInt64 value.

Return Value

Type: size_t
A size_t value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t Implicit Conversion (size_t to UInt64)

size_t Conversion (size_t to UInt64)
Converts a size_t value to a UInt64 value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static implicit operator ulong (
    size_t value
)
Public Shared Widening Operator CType (
    value As size_t
) As ULong
static implicit operator unsigned long long (
    size_t value
)
F# does not support the declaration of new casting operators.

Parameters

value
Type: Math.Gmp.Nativesize_t
An size_t value.

Return Value

Type: UInt64
A UInt64 value.
See Also

Reference

size_t Structure
Overload
Math.Gmp.Native Namespace


size_t.Inequality Operator

size_tInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    size_t value1,
    size_t value2
)
Public Shared Operator <> (
    value1 As size_t,
    value2 As size_t
) As Boolean
public:
static bool operator !=(
    size_t value1,
    size_t value2
)
static let inline (<>)
        value1 : size_t *
        value2 : size_t  : bool

Parameters

value1
Type: Math.Gmp.Nativesize_t
A size_t value.
value2
Type: Math.Gmp.Nativesize_t
A size_t value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t Fields

size_t Fields

The size_t type exposes the following members.

Fields
 | Name | Description
Public field | Value | The size_t value.
Top
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


size_t.Value Field

size_tValue Field
The size_t value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public ulong Value
Public Value As ULong
public:
unsigned long long Value
val mutable Value: uint64

Field Value

Type: UInt64
See Also

Reference

size_t Structure
Math.Gmp.Native Namespace


va_list Class

va_list Class
Represent a variable argument list.
Inheritance Hierarchy
SystemObject
Math.Gmp.Nativeva_list

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public class va_list
Public Class va_list
public ref class va_list
type va_list =  class end

The va_list type exposes the following members.

Constructors
 | Name | Description
Public method | va_list | Creates a variable list of arguments in unmanaged memory.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | RetrieveArgumentValues | Retrieves argument values from unmanaged memory.
Public method | ToIntPtr | Return the pointer to the list of arguments in unmanaged memory.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

Math.Gmp.Native Namespace


va_list Constructor

va_list Constructor
Creates a variable list of arguments in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public va_list(
    params Object[] args
)
Public Sub New (
    ParamArray args As Object()
)
public:
va_list(
    ... array<Object^>^ args
)
new :
        args : Object[] -> va_list

Parameters

args
Type: SystemObject
The list of arguments.
See Also

Reference

va_list Class
Math.Gmp.Native Namespace


va_list Methods

va_list Methods

The va_list type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
Public method | RetrieveArgumentValues | Retrieves argument values from unmanaged memory.
Public method | ToIntPtr | Return the pointer to the list of arguments in unmanaged memory.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object.)
Top
See Also

Reference

va_list Class
Math.Gmp.Native Namespace


va_list.RetrieveArgumentValues Method

va_listRetrieveArgumentValues Method
Retrieves argument values from unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public void RetrieveArgumentValues()
Public Sub RetrieveArgumentValues
public:
void RetrieveArgumentValues()
member RetrieveArgumentValues : unit -> unit
See Also

Reference

va_list Class
Math.Gmp.Native Namespace


va_list.ToIntPtr Method

va_listToIntPtr Method
Return the pointer to the list of arguments in unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
The pointer to the list of arguments in unmanaged memory.
See Also

Reference

va_list Class
Math.Gmp.Native Namespace


void_ptr Structure

void_ptr Structure
Represents a pointer to a block of unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public struct void_ptr
Public Structure void_ptr
public value class void_ptr
[<SealedAttribute>]
type void_ptr =  struct end

The void_ptr type exposes the following members.

Constructors
 | Name | Description
Public method | void_ptr | Creates new void_ptr from an exidting pointer to unmanaged memory.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(void_ptr) | Returns a value indicating whether this instance is equal to a specified void_ptr value.
Public method | FromIntPtr | Gets a void_ptr from a pointer to a block of unmanaged memory.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToIntPtr | Gets pointer to block of unmanaged memory.
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.)
Top
Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
Fields
Name | Description
Zero | Gets a null void_ptr.
Top
Remarks
See Also

Reference

Math.Gmp.Native Namespace


void_ptr Constructor

void_ptr Constructor
Creates new void_ptr from an exidting pointer to unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public void_ptr(
    IntPtr pointer
)
Public Sub New (
    pointer As IntPtr
)
public:
void_ptr(
    IntPtr pointer
)
new :
        pointer : IntPtr -> void_ptr

Parameters

pointer
Type: SystemIntPtr
Pointer to unmanaged memory.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr Methods

void_ptr Methods

The void_ptr type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(void_ptr) | Returns a value indicating whether this instance is equal to a specified void_ptr value.
Public method | FromIntPtr | Gets a void_ptr from a pointer to a block of unmanaged memory.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object.)
Public method | ToIntPtr | Gets pointer to block of unmanaged memory.
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.)
Top
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.Equals Method

void_ptrEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method | Equals(void_ptr) | Returns a value indicating whether this instance is equal to a specified void_ptr value.
Top
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.Equals Method (Object)

void_ptrEquals Method (Object)
Returns a value indicating whether this instance is equal to a specified object.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
abstract Equals :
        obj : Object -> bool
override Equals :
        obj : Object -> bool

Parameters

obj
Type: SystemObject
An object to compare with this instance.

Return Value

Type: Boolean
True if obj is an instance of void_ptr and equals the value of this instance; otherwise, False.
See Also

Reference

void_ptr Structure
Equals Overload
Math.Gmp.Native Namespace


void_ptr.Equals Method (void_ptr)

void_ptrEquals Method (void_ptr)
Returns a value indicating whether this instance is equal to a specified void_ptr value.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public bool Equals(
    void_ptr other
)
Public Function Equals (
    other As void_ptr
) As Boolean
public:
bool Equals(
    void_ptr other
)
member Equals :
        other : void_ptr -> bool

Parameters

other
Type: Math.Gmp.Nativevoid_ptr
A void_ptr value to compare to this instance.

Return Value

Type: Boolean
True if other has the same value as this instance; otherwise, False.
See Also

Reference

void_ptr Structure
Equals Overload
Math.Gmp.Native Namespace


void_ptr.FromIntPtr Method

void_ptrFromIntPtr Method
Gets a void_ptr from a pointer to a block of unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public void_ptr FromIntPtr(
    IntPtr value
)
Public Function FromIntPtr (
    value As IntPtr
) As void_ptr
public:
void_ptr FromIntPtr(
    IntPtr value
)
member FromIntPtr :
        value : IntPtr -> void_ptr

Parameters

value
Type: SystemIntPtr
A pointer to a block of unmanaged memory.

Return Value

Type: void_ptr
A void_ptr from a pointer to a block of unmanaged memory.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.GetHashCode Method

void_ptrGetHashCode Method
Returns the hash code for this instance.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override
abstract GetHashCode : unit -> int
override GetHashCode : unit -> int

Return Value

Type: Int32
A 32-bit signed integer hash code.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.ToIntPtr Method

void_ptrToIntPtr Method
Gets pointer to block of unmanaged memory.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public IntPtr ToIntPtr()
Public Function ToIntPtr As IntPtr
public:
IntPtr ToIntPtr()
member ToIntPtr : unit -> IntPtr

Return Value

Type: IntPtr
Pointer to block of unmanaged memory.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr Operators

void_ptr Operators

The void_ptr type exposes the following members.

Operators
Name | Description
Equality | Gets a value that indicates whether the two argument values are equal.
Inequality | Gets a value that indicates whether the two argument values are different.
Top
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.Equality Operator

void_ptrEquality Operator
Gets a value that indicates whether the two argument values are equal.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator ==(
    void_ptr value1,
    void_ptr value2
)
Public Shared Operator = (
    value1 As void_ptr,
    value2 As void_ptr
) As Boolean
public:
static bool operator ==(
    void_ptr value1,
    void_ptr value2
)
static let inline (=)
        value1 : void_ptr *
        value2 : void_ptr  : bool

Parameters

value1
Type: Math.Gmp.Nativevoid_ptr
A void_ptr value.
value2
Type: Math.Gmp.Nativevoid_ptr
A void_ptr value.

Return Value

Type: Boolean
True if the two values are equal, and False otherwise.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.Inequality Operator

void_ptrInequality Operator
Gets a value that indicates whether the two argument values are different.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static bool operator !=(
    void_ptr value1,
    void_ptr value2
)
Public Shared Operator <> (
    value1 As void_ptr,
    value2 As void_ptr
) As Boolean
public:
static bool operator !=(
    void_ptr value1,
    void_ptr value2
)
static let inline (<>)
        value1 : void_ptr *
        value2 : void_ptr  : bool

Parameters

value1
Type: Math.Gmp.Nativevoid_ptr
A void_ptr value.
value2
Type: Math.Gmp.Nativevoid_ptr
A void_ptr value.

Return Value

Type: Boolean
True if the two values are different, and False otherwise.
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr Fields

void_ptr Fields

The void_ptr type exposes the following members.

Fields
Name | Description
Zero | Gets a null void_ptr.
Top
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace


void_ptr.Zero Field

void_ptrZero Field
Gets a null void_ptr.

Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
C++
F#
Copy
public static readonly void_ptr Zero
Public Shared ReadOnly Zero As void_ptr
public:
static initonly void_ptr Zero
static val Zero: void_ptr

Field Value

Type: void_ptr
See Also

Reference

void_ptr Structure
Math.Gmp.Native Namespace