High precision arithmetic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

High precision arithmetic

Pierre Chanson
Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C...
Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)

Thanks !

Pierre
Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Marcus Denker-4

On 02 Feb 2015, at 17:22, Pierre CHANSON <[hidden email]> wrote:

Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C…


Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)


I always thought that we should look into using MPFR.

There is no way that we have the knowledge or manpower to recreate that.



Marcus

Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

stepharo
In reply to this post by Pierre Chanson
Pay attention ScaledDecimal are just fraction.

Le 2/2/15 17:22, Pierre CHANSON a écrit :

> Hi everyone,
> I was wondering if there was a package to manipulate floats like the
> MPFR library in C...
> Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf 
> that using ScaledDecimal allows exact arithmetics. So I guess
> ScaledDecimal is the best class to use for playing with 20 decimals
> numbers ? :)
>
> Thanks !
>
> Pierre


Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

wernerk
In reply to this post by Marcus Denker-4
Hi Pierre,
you will find an ArbitraryPrecisionFloat package at sqeaksource that
works eg in pharo3 & 4:
http://www.squeaksource.com/ArbitraryPrecisionFl.html
werner

Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

stepharo
In reply to this post by Marcus Denker-4

Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)


I always thought that we should look into using MPFR.

There is no way that we have the knowledge or manpower to recreate that.



Indeed we could define a plugin.


Marcus


Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

philippeback
In reply to this post by Pierre Chanson
On Mon, Feb 2, 2015 at 5:22 PM, Pierre CHANSON <[hidden email]> wrote:
Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C...

One issue with MPFR is the licensing, which is GNU.

I wonder if Pharo couldn't get a special licence for embedding as "MPFR has continuously been supported by the INRIA...".

Pharo is now 32-bit and uses the floatplugin to do the actual fast math.

Pharo with the 64-bit system will be able to do better and the float plugin will have to be rewritten anyway.

But MPFR could be put into a plugin.

As far as I am concerned, I'd rather get something based on GMP (https://gmplib.org/) but we are there in GNU territory. Which is not what I want for commercial apps.

This table: http://www.mpfr.org/mpfr-current/timings.html is showing some LGPL licencing that may be easier to deal with. But for sure, none of that is MIT :-(

Phil

 
Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)

Thanks !

Pierre




Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Pierre Chanson
In reply to this post by stepharo

2015-02-02 13:49 GMT-03:00 stepharo <[hidden email]>:
Pay attention ScaledDecimal are just fraction.

Yes sure but I think it would be ok for me later, for example using  ScaledDecimal readFrom: '0.000006515031360099368', then I can manipulate this.

Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Pierre Chanson
In reply to this post by wernerk

2015-02-02 13:51 GMT-03:00 Werner Kassens <[hidden email]>:
Hi Pierre,
you will find an ArbitraryPrecisionFloat package at sqeaksource that works eg in pharo3 & 4:
http://www.squeaksource.com/ArbitraryPrecisionFl.html


Thanks Werner, I will have a look
Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Marcus Denker-4
In reply to this post by philippeback

On 02 Feb 2015, at 17:58, [hidden email] wrote:

On Mon, Feb 2, 2015 at 5:22 PM, Pierre CHANSON <[hidden email]> wrote:
Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C...

One issue with MPFR is the licensing, which is GNU.

I wonder if Pharo couldn't get a special licence for embedding as "MPFR has continuously been supported by the INRIA...".

Pharo is now 32-bit and uses the floatplugin to do the actual fast math.

Pharo with the 64-bit system will be able to do better and the float plugin will have to be rewritten anyway.

But MPFR could be put into a plugin.

As far as I am concerned, I'd rather get something based on GMP (https://gmplib.org/) but we are there in GNU territory. Which is not what I want for commercial apps.

This table: http://www.mpfr.org/mpfr-current/timings.html is showing some LGPL licencing that may be easier to deal with. But for sure, none of that is MIT :-(

Libc on unix is LGPL, too… it works well for C style libraries.

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

HilaireFernandes
In reply to this post by Pierre Chanson
Le 02/02/2015 19:11, Pierre CHANSON a écrit :

>
> 2015-02-02 13:49 GMT-03:00 stepharo
> <[hidden email]
> <mailto:[hidden email]>>:
>
>     Pay attention ScaledDecimal are just fraction.
>
>
> Yes sure but I think it would be ok for me later, for example using
> ScaledDecimal readFrom: '0.000006515031360099368', then I can manipulate
> this.


As informative as it could be, in computation it appears to me
ScaledDecimal are slower than Float.

Hilaire


--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

stepharo
In reply to this post by wernerk
we should move it to scitalk ;)
Le 2/2/15 17:51, Werner Kassens a écrit :
> Hi Pierre,
> you will find an ArbitraryPrecisionFloat package at sqeaksource that
> works eg in pharo3 & 4:
> http://www.squeaksource.com/ArbitraryPrecisionFl.html
> werner
>
>


Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

wernerk
Hi Stephane,
<g> it _is_ in scitalk, at the moment only in the #development version,
but i'd guess, that will change in a while.

Hi Pierre, the problem - as Stephane pointed out - is that ScaledDecimal
essentially is a Fraction, which depending on which function you use can
be transformed to Float, iow you _can_ loose precision with it, i'd be
careful and look at the implementations of the functions you use in
Fraction; as far as i can see, ScaledDecimals reason of existence is not
really to make arbitrary precision calculations possible. otoh
ArbitraryPrecisionFloat is a package, that is not really fast, but as
precise as you want it to be (with the implemented functions).
werner

On 02/02/2015 09:43 PM, stepharo wrote:

> we should move it to scitalk ;)
> Le 2/2/15 17:51, Werner Kassens a écrit :
>> Hi Pierre,
>> you will find an ArbitraryPrecisionFloat package at sqeaksource that
>> works eg in pharo3 & 4:
>> http://www.squeaksource.com/ArbitraryPrecisionFl.html
>> werner
>>
>>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Ben Coman
In reply to this post by philippeback


On Tue, Feb 3, 2015 at 12:58 AM, [hidden email] <[hidden email]> wrote:
On Mon, Feb 2, 2015 at 5:22 PM, Pierre CHANSON <[hidden email]> wrote:
Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C...

One issue with MPFR is the licensing, which is GNU.

No, its LGPL (http://www.mpfr.org/).  Now something I didn't know and just read, you can even statically link an LGPL library, as long as you provide 
 

I wonder if Pharo couldn't get a special licence for embedding as "MPFR has continuously been supported by the INRIA...".

Pharo is now 32-bit and uses the floatplugin to do the actual fast math.

Pharo with the 64-bit system will be able to do better and the float plugin will have to be rewritten anyway.

But MPFR could be put into a plugin.

As far as I am concerned, I'd rather get something based on GMP (https://gmplib.org/) but we are there in GNU territory. Which is not what I want for commercial apps.


Why GMP? From the timings table it looks like GMP is missing trigonometric functions, and  that MPFR is equally as fast as GMP.
cheers -ben
 

This table: http://www.mpfr.org/mpfr-current/timings.html is showing some LGPL licencing that may be easier to deal with. But for sure, none of that is MIT :-(

Phil

 
Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)

Thanks !

Pierre





Reply | Threaded
Open this post in threaded view
|

Re: High precision arithmetic

Pierre Chanson
Hi Werner, you are right, I will try it

2015-02-03 10:22 GMT-03:00 Ben Coman <[hidden email]>:


On Tue, Feb 3, 2015 at 12:58 AM, [hidden email] <[hidden email]> wrote:
On Mon, Feb 2, 2015 at 5:22 PM, Pierre CHANSON <[hidden email]> wrote:
Hi everyone,
I was wondering if there was a package to manipulate floats like the MPFR library in C...

One issue with MPFR is the licensing, which is GNU.

No, its LGPL (http://www.mpfr.org/).  Now something I didn't know and just read, you can even statically link an LGPL library, as long as you provide 
 

I wonder if Pharo couldn't get a special licence for embedding as "MPFR has continuously been supported by the INRIA...".

Pharo is now 32-bit and uses the floatplugin to do the actual fast math.

Pharo with the 64-bit system will be able to do better and the float plugin will have to be rewritten anyway.

But MPFR could be put into a plugin.

As far as I am concerned, I'd rather get something based on GMP (https://gmplib.org/) but we are there in GNU territory. Which is not what I want for commercial apps.


Why GMP? From the timings table it looks like GMP is missing trigonometric functions, and  that MPFR is equally as fast as GMP.
cheers -ben
 

This table: http://www.mpfr.org/mpfr-current/timings.html is showing some LGPL licencing that may be easier to deal with. But for sure, none of that is MIT :-(

Phil

 
Then I found in http://stephane.ducasse.free.fr/Web/Draft/Float.pdf that using ScaledDecimal allows exact arithmetics. So I guess ScaledDecimal is the best class to use for playing with 20 decimals numbers ? :)

Thanks !

Pierre