gmp_libmpz_out_str Method |
Namespace: Math.Gmp.Native
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.
// 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);