caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] What library to use for arbitrary precision decimals
Date: Sun, 19 Feb 2006 10:53:47 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.63.0602191046300.17832@localhost.localdomain> (raw)
In-Reply-To: <20060219163838.GA32465@furbychan.cocan.org>



On Sun, 19 Feb 2006, Richard Jones wrote:

>
> Before we go too far down the currency track (where I agree, using
> integers is the way to go), my actual requirement is for a natural
> OCaml mapping for the PostgreSQL NUMERIC/DECIMAL type:
>
> http://www.postgresql.org/docs/current/interactive/datatype.html#DATATYPE-NUMERIC-DECIMAL
>
> The database can define types like NUMERIC(6,4) which means 6 decimal
> digits in total, 4 of them after the decimal point -- for example,
> 12.3456

Hmm.  There are problems definin that library.  What are the semantics? 
If I add a NUMERIC(6,4) (2 digits to the left of the point and 4 to the 
righ) and a NUMERIC(7,2) (5 digits to the left of the point and 2 to the 
right), what precision is the result?  NUMERIC(4,2) (2 digits to the left 
of the point and 2 to the right)?  NUMERIC(9,4) (5 digits to the left of 
the point and 4 digits to the right)?  How does roundoff work?  If I take 
the NUMERIC(6,4) number 62.0000 and multiply it by the NUMERIC(6,4) number 
02.0000, what answer do I get?  The NUMERIC(6,4) number 24.000?  The 
NUMERIC(7,4) number 124.000?  Or does it throw an exception?

>
> There doesn't seem to me to be a good natural map for this type in the
> stdlib.

If decimal roundoff isn't important, I'd be tempted to go for floats.  I 
don't know if this is true or not.

Brian


  reply	other threads:[~2006-02-19 16:53 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 [this message]
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
  -- 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.0602191046300.17832@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /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).