[Numpy-discussion] longdouble (float96) literals

Charles R Harris charlesr.harris@gmail....
Wed Aug 18 09:14:38 CDT 2010

On Wed, Aug 18, 2010 at 7:37 AM, Colin Macdonald

> On 08/18/10 13:43, Charles R Harris wrote:
> >
> >
> > On Wed, Aug 18, 2010 at 3:46 AM, Colin Macdonald
> > <macdonald@maths.ox.ac.uk <mailto:macdonald@maths.ox.ac.uk>> wrote:
> >
> >     How can I enter longdouble (float96) literals into my python/numpy
> >     programs?  In C, I would postfix such numbers with 'L', but this
> gives
> >     a SyntaxError in python.
> >
> > I don't know how to do this without using strings and having numpy do
> > it's own string conversions. IIRC, we currently rely on Python for
> > this and Python doesn't support long doubles. You might open a ticket
> > with a request for an enhancement as we should fix this at some point.
> I'd be at least partially satisfied with doing a string conversion ;-)
> How would I do that?  Is there something like strtolongdouble()?  Or a
> sscanf function?
If you are willing to work at the C-Level you can probably use sscanf with
the proper format specifier. Or you might write a parser in python. Numpy
just doesn't have support for this at the moment, at least not that I am
aware of. However, the various constants supplied by numpy, pi and such, are
full precision.

> I will try to remember to open a ticket for the issue.
> Perhaps the issue that numpy.longdouble("0.4") doesn't work properly a
> slightly separate bug...

I'm pretty sure it goes through a double and can't be fixed until there is
long double support for string conversions. Unicode makes this even trickier
as to use the C-library it needs to be converted to ascii first.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100818/5896c489/attachment.html 

More information about the NumPy-Discussion mailing list