Re: Multi precision floating point



jacob navia wrote:
Philip Potter wrote:
jacob navia wrote:
mathieu.dutour@xxxxxxxxx wrote:
Dear all,

I want to do multiprecision floating point, i.e. I want
to go beyond single precision, double precision and have
quadruple precision, octuple precision and the like,
and possibly with high speed.

What would be the possible alternatives?
Thanks for any help

Mathieu
lcc-win proposes qfloat precision (352 bits, 107 digits)
and bignums, that can be arbitrarily big.
A whole three minutes to advertise your compiler, jacob? You're getting slow.

To the OP: jacob's compiler does indeed provide this feature. If you simply want to use 352-bit floating point, and only ever envisage using your code on a platform which jacob implements his compiler on, and are happy with sticking with one compiler for the lifetime of your project, then by all means go ahead.

If, on the other hand, you want to write multiple-precision floating-point as a learning exercise, or you forsee ever needing to use your code on an implementation other than jacob's, or you simply want to keep the choice of switching vendors, then it is perfectly possible to write multiple-precision floating-point in Standard C.

Philip

If you are interested in portability of your code
you do

#ifdef __LCC__
typedef qfloat FLOAT_TYPE;
#else
typedef long double FLOAT_TYPE;
#endif

and you see that all your float types are declared accordingly.

This only provides portability to implementations where 'long double' has the required precision. These are remarkably few.

Within lcc-win qfloat are just another floating point type:

qfloat a = 122333223332323.778887787766656544e7987Q;

Note the "Q" at the end.

In other libraries, the initialization of big numbers is done using
strings, and not at the global level. You may want to do that if you
use another library.

That is because those are libraries, whereas qfloat is a language extension, which adds to the C syntax - something libraries cannot do.

From all the other libraries, most do not fit well within C due to the
standard language lack of operator overloading.

lcc-win offers operator overloading, and it allows integrating
a large number of libraries within it to do what you want.

And for this reason it may be difficult to port a qfloat program to another platform.

I have to say, I actually agree that operator overloading provides a nicer interface for dealing with floating-point numbers (or complex, or fixed-point, or whatever); but C doesn't allow operator overloading, so if you want your program to be C, you must eschew it.
.



Relevant Pages

  • Re: Multi precision floating point
    ... to go beyond single precision, ... If you simply want to use 352-bit floating point, and only ever envisage using your code on a platform which jacob implements his compiler on, and are happy with sticking with one compiler for the lifetime of your project, then by all means go ahead. ... If, on the other hand, you want to write multiple-precision floating-point as a learning exercise, or you forsee ever needing to use your code on an implementation other than jacob's, or you simply want to keep the choice of switching vendors, then it is perfectly possible to write multiple-precision floating-point in Standard C. ... From all the other libraries, most do not fit well within C due to the ...
    (comp.lang.c)
  • Re: Multi precision floating point
    ... to go beyond single precision, ... A whole three minutes to advertise your compiler, jacob? ... jacob's compiler does indeed provide this feature. ... If, on the other hand, you want to write multiple-precision floating-point as a learning exercise, or you forsee ever needing to use your code on an implementation other than jacob's, or you simply want to keep the choice of switching vendors, then it is perfectly possible to write multiple-precision floating-point in Standard C. ...
    (comp.lang.c)
  • Re: example of KIND to replace DOUBLE PRECISION
    ... precision kind parameters defined. ... what do you do when you need to use multiple libraries? ...
    (comp.lang.fortran)
  • Re: Sine code for ANSI C
    ... > where it's okay to stop delivering accurate results? ... When they use a single precision function they expect ... > scale to professional libraries licensed to professional ...
    (comp.lang.c)
  • Re: single precision
    ... likely calling single-precision versions of the underlying libraries, ... libraries are explicitly declared as higer precision variables in the ... compiler may automatically do some intermediate calculations in double ...
    (comp.soft-sys.matlab)