Re: Need more precision.
by RichardK (Parson) on Jun 09, 2015 at 22:46 UTC
|
Did you see this ? Quadruple-precision_floating-point_format It looks like there are a few libraries, at least one, QPFloat, with a windows version.
I haven't used it myself, so I know nothing else about it ;)
| [reply] |
|
| [reply] |
|
| [reply] |
|
Re: Need more precision.
by roboticus (Chancellor) on Jun 09, 2015 at 21:40 UTC
|
BrowserUk:
Update: I just read the article in more detail, and I don't think it's what you want.
I've not used it, but the xmmintrin.h header file contains some functions to work with SSE numbers. You might look at it see if it suits. An article I tripped over seems to provide some explanation:http://www.codeproject.com/Articles/4522/Introduction-to-SSE-Programming. I only skimmed the article, so I don't know if it has enough detail to get you going.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
|
I just read the article in more detail, and I don't think it's what you want.
Indeed. I wasted an afternoon trying to find some way to get more precision out of SSE/2 but they are about SIMD; performing multiple (2xdouble or 4xfloat) operations in parallel.
I don't see any way to get more precision out of them. I thought for a while it might be possible to use two doubles as a kind limited kind of multi-precision, but there is no carry-over facility.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
| [reply] |
Re: Need more precision.
by Tux (Canon) on Jun 10, 2015 at 06:25 UTC
|
As nobody mentioned this so far, I'll bite on "perl has not and my compiler has" part. Perl by default configures/compiles to "normal" doubles, but it has an option to use long doubles for NV types.
Configure your perl with -Duselongdouble
$ perl -V:uselongdouble\|nvsize
nvsize='16';
uselongdouble='define';
$ perl -MData::Dumper -wE'say Dumper cos 1'
$VAR1 = '0.540302305868139717';
$ perl5.10.1 -V:uselongdouble\|nvsize
nvsize='8';
uselongdouble='undef';
$ perl5.10.1 -MData::Dumper -wE'say Dumper cos 1'
$VAR1 = '0.54030230586814';
$
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
|
Configure your perl with -Duselongdouble
On Windows, you can build in long double support only with perl-5.22.0 and later ... and even then only if you're using a MinGW port of the gcc compiler.
Cheers, Rob
| [reply] |
|
My compiler (MSVC) "supports" the long double type, but "The long double type is identical to the double type."
So it does me no good at all. Thanks for the thought though :)
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
| [reply] |
Re: Need more precision.
by Anonymous Monk on Jun 09, 2015 at 21:39 UTC
|
Hmm, going down the fixed-point route, in 2011 you asked: Module for 128-bit integer math?, which resulted in Math::Int128... test stats in Windows look a bit spotty, but it looks like it's actively maintained and maybe worth a try?
| [reply] |
|
| [reply] |
|
Got that, but Fixed-point arithmetic "is essentially an integer that is scaled by an implicit specific factor determined by the type. For example, the value 1.23 can be represented as 1230 in a fixed-point data type with scaling factor of 1/1000". This should work since you said your min/max is -4.0 to 4.0, which could be represented in a 128-bit integer as, for example, 0 to 80000000000000000000000000000000000000.
| [reply] |
|
|
|
|
| [reply] |
Re: Need more precision.
by u65 (Chaplain) on Jun 09, 2015 at 20:56 UTC
|
Why is arbitrary precision not an alternative? There are several CPAN modules offering such (e.g., Math::BigFloat).
| [reply] |
|
Let me clarify.
I know about arbitrary precision. I mentioned it in the OP.
So, if it was a viable option, there would be no need to ask the question, because I would just use that.
I'm looking to see what alternatives there are; so you questioning why I don't want to use arbitrary precision does nothing to help me in my quest.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
| [reply] |
|
Again I respectfully ask, what all constraints are you under, otherwise this seems to be a rabbit hunt.
| [reply] |
|
|
|
|
|
|
| [reply] |
|
Perhaps you could enlighten us on all the constraints you have to labor under.
| [reply] |
|
Re: Need more precision.
by Anonymous Monk on Jun 09, 2015 at 20:35 UTC
|
Min and max?
Just a few digits more, or even more than that?
Which compiler?
| [reply] |
|
| [reply] |
|
How about fixed point arithmetic? If 18 digits really is "good enough", then a signed 64 bit int will give you 18 digits (int part plus 17 decimal places). If you need more, does the compiler have a 128 bit int type? If not, you could code routines that cascade a signed 64 with an unsigned 64 to give you a signed 128.
| [reply] |
|
|
|
|
|
|
|