[geos-devel] double double

Darafei "Komяpa" Praliaskouski me at komzpa.net
Sat Dec 8 00:19:05 PST 2018


On Sat, Dec 8, 2018 at 6:51 AM Greg Troxel <gdt at lexort.com> wrote:

> Paul Ramsey <pramsey at cleverelephant.ca> writes:
>
> > Mats, what ever happened to:
> >
> > https://github.com/libgeos/geos/pull/40
> >
> > I'm just coming up against some stuff in the JTS commit log that expects
> > double double and I see you've done this work already some years ago, but
> > it's not committed that I can see. JTS changed over some code to use DD
> > exclusively about a year ago, so this is a case where porting has caught
> up
> > to need.
> >
> > Were there any substantial problems w/ your PR? If not I'm "just" going
> to
> > try and rebase it and use it as the basis for going ahead.
> >
> > (It seems like the state-of-the-art would eventually be to use the "long
> > double" type, which has an implementation in GCC, but does not yet have
> one
> > in clang, in hopes that by being close to the metal we'd eventually also
> > start to reap performance gains as the silicon adds instructions to
> improve
> > long double calculations. ???)
>
> I don't follow this last paragraph.
>
> As I understand it, long double is a type defined by C that can be more
> precise than double, but doesn't have to be, and on x86 is typically 80
> bits.  double double is a technique to use two doubles to get roughly
> twice the precision.   I would expect that on many CPUs, long double is
> the same as double.
>

Windows defines long double to be the same as double. Java doesn't even
have long double, so JTS has no choice for intermediate storage.

Redefining some intermediate variables as long double short term is a cheap
gain.
Double double gives a bigger gain but is more painful.

It is not enough to be robust in all cases also though - here
are Shewchuk's proved-robust predicates that have to use up to four doubles
to manage long arithmetic:

https://www.cs.cmu.edu/~quake/robust.html

https://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c

If you find 512-bit float somewhere you may get away with it directly
though, but I don't think they are available on consumer non-DSP CPUs.



> So double double is far more precise than long double always.
>
> https://en.wikipedia.org/wiki/Long_double
>
> https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geos-devel



-- 
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20181208/ce3a6405/attachment.html>


More information about the geos-devel mailing list