caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Jeremy Shute <shutej@gmail.com>
Cc: Joshua Smith <kognate@gmail.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] What library to use for arbitrary precision decimals
Date: Sun, 19 Feb 2006 12:31:38 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.63.0602191217290.17832@localhost.localdomain> (raw)
In-Reply-To: <8c64de0a0602190921y557577f8pc3114e0bbeb1aa56@mail.gmail.com>



On Sun, 19 Feb 2006, Jeremy Shute wrote:

> If you use the Int64 module as the basis for your computations, you can
> hold values up to $184,467,440,737,095.51 in size.
>
> How many Vietnamese Dongs is that?  Some CIA factbook estimates of the GDP
> of the world:
>
> $US 5.938e+13
>
> One dollar will buy you a lot of Vietnamese Dongs:
>
> $VND 1.5838e+4

>
> So, the GDP of the world (a popular number, to be sure) is about:
>
> $VND 9.4046e+17
>
> ...and the the max signed int64 is around...
>
> 9.2234e+18
>
> This is not an isolated case, there are quite a few currencies in the $? 10K
> / $US 1 range.  Point: you're one locale change and some depreciation away
> from overflowing when someone wants to calculate a ratio for analysis.  Why
> not use a big int?

You're right that if you're needing to calculate the World GDP, or even 
the American debt, you may need more bits.  Although I was doing stuff in 
millipennies, simply doing stuff in centipennies still leaves you enough 
information to round to the nearest penny correctly, and gives you another 
order of magnitude headroom.

The reason to use Int64 instead of Bigint is performance.  This may or may 
not be an issue.  Although I note that both Bigint and Int64 performance 
is going to way stomp BCD performance.

Brian


  reply	other threads:[~2006-02-19 18:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-19 13:43 Joshua Smith
2006-02-19 15:44 ` [Caml-list] " Brian Hurt
2006-02-19 16:38   ` Richard Jones
2006-02-19 16:53     ` Brian Hurt
2006-02-19 17:00       ` Richard Jones
2006-02-19 17:13         ` Richard Jones
2006-02-19 17:21   ` Jeremy Shute
2006-02-19 18:31     ` Brian Hurt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-02-19 10:18 Richard Jones
2006-02-19 14:03 ` [Caml-list] " Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0602191217290.17832@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=kognate@gmail.com \
    --cc=shutej@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).