Re: [julia-dev] Specify the precision of Julia bigfloats.

142 views
Skip to first unread message

Stefan Karpinski

unread,
Aug 27, 2012, 2:56:21 PM8/27/12
to juli...@googlegroups.com
It's entirely possible and the best approach is probably to write bindings for an appropriate arbitrary-precision floating-point library. See extras/bigint.jl for an example defining a BigInt type using GMP. The floating-point library that "accompanies" GMP is GMPFR, so that seems like a likely candidate for BigFloat functionality.

On Mon, Aug 27, 2012 at 2:26 PM, kilobyte <moiloa...@gmail.com> wrote:
Is it possible to have an arbitrarily large Julia bigfloat? If not is it somehow difficult to implement?

--




Avik Sengupta

unread,
Aug 28, 2012, 5:07:17 AM8/28/12
to juli...@googlegroups.com
there is also a extras/bigfloat.jl, that wraps GMP's floating point functions. 

kilobyte

unread,
Aug 28, 2012, 8:18:54 AM8/28/12
to juli...@googlegroups.com
In bigfloat.jl, I see dlopen("libgmp_wrapper"), where is the source code for libgmp_wrapper.so and why can't you just call dlopen("libgmp") directly?

Avik Sengupta

unread,
Aug 28, 2012, 8:32:29 AM8/28/12
to juli...@googlegroups.com
The GMP functions use and return structs (specifically the  mpz_t and mpf_t structures). It is difficult to pass strucs back and forth between julia and C (although some heroic partial efforts to that end have been made in strpack.jl in extras since that then) . Further, the GMP interface is resolved at compile time via pre-processing ... the actual exported functions in the binary are mangled and system dependent. 

For these reasons, a C wrapper is used to interface between julia and GMP. The source for that is in deps/gmp_wrapper.c. It may be possible to do this via pure julia. However, at the time, it seemed like the path of least resistance. 

Regards
-
Avik

Stefan Karpinski

unread,
Aug 28, 2012, 11:10:13 AM8/28/12
to juli...@googlegroups.com
Yes, although it's not ideal to write wrappers, in the case of GMP and possibly in the case of GMFPR, this might be the best way to go.

--
 
 
 

Reply all
Reply to author
Forward
0 new messages