<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
    <channel>
        <title>Silas Sewell - October 2008</title>
        <atom:link href="http://www.silassewell.com/blog/2008/10/rss2.xml" rel="self" type="application/rss+xml" />
        <link>http://www.silassewell.com/blog/2008/10</link>
        <description>Infrastructure Development</description>
        <lastBuildDate>Sat, 21 Aug 2010 00:00:00 GMT</lastBuildDate>
        <generator>http://www.silassewell.com/</generator>
        <language>en</language>
        <sy:updatePeriod>hourly</sy:updatePeriod>
        <sy:updateFrequency>1</sy:updateFrequency>

        <item>
            <title>C GMP Hello World on Leopard (OS X 10.5)</title>
            <link>http://www.silassewell.com/blog/2008/10/19/c-gmp-hello-world-on-leopard-os-x-105/</link>
            <pubDate>Sun, 19 Oct 2008 00:00:00 GMT</pubDate>
            <dc:creator>silas</dc:creator>
            <category><![CDATA[C]]></category><category><![CDATA[GMP]]></category><category><![CDATA[Hello World]]></category><category><![CDATA[Mathematics]]></category><category><![CDATA[Programming]]></category>
            <guid isPermaLink="true">http://www.silassewell.com/blog/2008/10/19/c-gmp-hello-world-on-leopard-os-x-105/</guid>
            <description><![CDATA[<p>A simple <a href="http://gmplib.org/" title="GMP">GMP</a> Hello World example in C.</p>

<h3>Makefile</h3>

<pre><code class="prettyprint">all:
    gcc -o gmp_hello_world gmp_hello_world.c -lgmp -m64

clean:
    rm gmp_hello_world
</code></pre>

<h3>gmp_hello_world.c</h3>

<pre><code class="prettyprint">/*
 * GMP Hello World on OS X 10.5
*/
#include &lt;gmp.h&gt;
#include &lt;stdio.h&gt;

int main() {
  mpz_t add_total1, add_total2, sub_total1, sub_total2, mul_total1, mul_total2;
  mpz_t num1, num2;

  // Initialize variables
  mpz_init_set_str(num1, "345192567923875922375736284875732", 10);
  mpz_init_set_str(num2, "937929298382994742939293857584837", 10);
  mpz_init(add_total1);
  mpz_init(add_total2);
  mpz_init(sub_total1);
  mpz_init(sub_total2);
  mpz_init(mul_total1);
  mpz_init(mul_total2);

  // Do arithmetic
  mpz_add(add_total1, num1, num2);
  mpz_add_ui(add_total2, num1, 10);
  mpz_sub(sub_total1, num1, num2);
  mpz_sub_ui(sub_total2, num1, 10);
  mpz_mul(mul_total1, num1, num2);
  mpz_mul_ui(mul_total2, num1, 10);

  // Display results
  gmp_printf("Add Total 1: %Zd\n", add_total1);
  gmp_printf("Add Total 2: %Zd\n", add_total2);
  gmp_printf("Subtract Total 1: %Zd\n", sub_total1);
  gmp_printf("Subtract Total 2: %Zd\n", sub_total2);
  gmp_printf("Multiply Total 1: %Zd\n", mul_total1);
  gmp_printf("Multiply Total 2: %Zd\n", mul_total2);

  // Free space
  mpz_clear(num1);
  mpz_clear(num2);
  mpz_clear(add_total1);
  mpz_clear(add_total2);
  mpz_clear(sub_total1);
  mpz_clear(sub_total2);
  mpz_clear(mul_total1);
  mpz_clear(mul_total2);

  return 0;
}
</code></pre>]]></description>
        </item>

    </channel>
</rss>