[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gmp] [Fwd: gmp and rounding]

From: Torbjorn Granlund
Subject: Re: [Bug-gmp] [Fwd: gmp and rounding]
Date: 03 Aug 2000 16:09:38 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.6

"Markus Eurich" <address@hidden> writes:

  > Hello people,
  > the gmp - libaray is very fast at the floating - point operatation. But
  > i miss a function to round a value.
  > example:    3.141    round to the second position after the point    ->
  > 3.14
  > If there any undocument function for this or any other chance to do
  > this?

Since GMP doesn't use decimal representation internally, it wouldn't
be simple to implement what you suggest.  I also fail to see any use
for it.  Normally one wants to compute to full precision and then
print fewer digits at the end, and GMP supports exactly that.

If you really want to round at a decimal position, use mpf_get_str and
then call mpf_set_str with the result.  Of course, most numbers will
then be represented as an approximation internally, again since the
internally represented is not decimal.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]