Re: Multi precision floating point
- From: Philip Potter <pgp@xxxxxxxxxxxx>
- Date: Wed, 28 Nov 2007 17:21:36 +0000
jacob navia wrote:
Philip Potter wrote:jacob navia wrote:mathieu.dutour@xxxxxxxxx wrote:A whole three minutes to advertise your compiler, jacob? You're getting slow.Dear all,lcc-win proposes qfloat precision (352 bits, 107 digits)
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
and bignums, that can be arbitrarily big.
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.
.
- Follow-Ups:
- Re: Multi precision floating point
- From: mathieu . dutour
- Re: Multi precision floating point
- References:
- Multi precision floating point
- From: mathieu . dutour
- Re: Multi precision floating point
- From: jacob navia
- Re: Multi precision floating point
- From: Philip Potter
- Re: Multi precision floating point
- From: jacob navia
- Multi precision floating point
- Prev by Date: Re: Historical question, why fwrite and not binary specifier for fprintf?
- Next by Date: Re: What does the following preprocessor directive do?
- Previous by thread: Re: Multi precision floating point
- Next by thread: Re: Multi precision floating point
- Index(es):
Relevant Pages
|