On Sun, 19 Jun 2011, Rob Dixon wrote:

On 19/06/2011 14:07, Patrick Dupre wrote:
Hello,

I need to convert the result of an aritmetic operation on 2
bignum into a "normal" float (ie double)

I did not find a way to do this.
no bignum ;
my $res = $A - $B ;

gives me always a bignum ($res) if $A and $B are bignum.

Hey Patrick

I suggest you convert the values to strings, which will force them to be
converted to normal floats before the arithmetic is done.

no bignum ;
my $res = $A->bstr - $B->bstr;
There is not option like (double) $res ?


It is also probably better to use Math::BigFloat instead of bignum, so
that you can better control which variables are big floats and which are
normal.

I also wonder why you want to convert big floats into normal ones? The
only reason I can think of is to improve execution speed.

Not really, I have a big application calling c procedures
and I do not want to make changes with are not usuable and even tricky.
However, I need to make a couple of operations in BigFloat.


--
---
==========================================================================
 Patrick DUPRÉ                      |   |
 Department of Chemistry            |   |  Phone: (44)-(0)-1904-434384
 The University of York             |   |  Fax:   (44)-(0)-1904-432516
 Heslington                         |   |
 York YO10 5DD  United Kingdom      |   |  email: patrick.du...@york.ac.uk
==========================================================================
-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

Reply via email to