Skip to content

Implement the 128-bit floating point number type #7647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
NeilGirdhar opened this issue May 18, 2016 · 20 comments
Open

Implement the 128-bit floating point number type #7647

NeilGirdhar opened this issue May 18, 2016 · 20 comments

Comments

@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented May 18, 2016

Boost does it; could we just depend on Boost's implementation? http://www.boost.org/doc/libs/1_58_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/float128.html

@charris
Copy link
Member

charris commented May 18, 2016

Best to keep the issues together rather than open a new one. We can borrow from boost but can't use c++, so some work would be needed, especially for the Python long type which is not stored as a common integer type. We could always go through a string, but that seems a bit unwieldy.

@NeilGirdhar
Copy link
Contributor Author

NeilGirdhar commented May 18, 2016

Which issue is this a duplicate of? I only added the bug because I couldn't find one.

@NeilGirdhar
Copy link
Contributor Author

(#5272 just says to rename float128 to be float80_96 or float80_128 depending on the platform, which is different from implementing float128).

@charris
Copy link
Member

charris commented May 18, 2016

If you mean true ieee quad precision, there should be something somewhere. Note that it is not generally supported by C, which has only the long double type, so it gets more complicated, especially if you want to support trig functions and such. There are some mailing list posts if that is what you mean, but adding the quad type would be some significant work. Note that gcc provide a library for that.

@NeilGirdhar
Copy link
Contributor Author

To be honest, I'm not really interested in this feature. I only created the bug because I couldn't find it.

@mhvk
Copy link
Contributor

mhvk commented May 18, 2016

I think it would be very worthwhile to have a proper float128, so having an open issue to track that seems appropriate.

@mhvk
Copy link
Contributor

mhvk commented May 30, 2019

As I have been implementing yet another class using a hack with two doubles, thought I'd ping here. It seems there is an IEEE standard for proper float128 and gcc supports it on what seems a very complete list of processors [1].

It seems fine if this would just replace the current float128.

[1] https://www.gnu.org/software/libc/manual/html_node/Mathematics.html

@rgommers
Copy link
Member

What about other compilers? A GCC-specific change will just make the confusion worse I'm afraid.

@seberg
Copy link
Member

seberg commented May 30, 2019

Maybe we should deprecate the float128 name? If users switch to np.longdouble instead, the name clears up for proper 128bit IEEE floating point numbers.

@NeilGirdhar
Copy link
Contributor Author

float128 and float96 seem much clearer than `longdouble'.

@seberg
Copy link
Member

seberg commented May 30, 2019

@NeilGirdhar yes, but they are also completely misleading and ill defined. longdouble at least is clear about mapping to the C long double definition.

@mhvk
Copy link
Contributor

mhvk commented May 30, 2019

@rgommers - some googling suggests both the llwm and the intel compiler also support it, though the latter perhaps not trivially (but presumably we can get some help from the intel folks). Are there other compilers are you thinking about?

Since currently np.float128 is not guaranteed to exist either, I'm not sure the situation will be worse than it is now. At least, if it exists, it will have consistent behaviour...

@mhvk
Copy link
Contributor

mhvk commented May 30, 2019

Deprecating float128 in favour of longdouble would seem to make sense - as noted, it at least has the benefit of not suggesting what precision or storage requirement the type has. Though there still is a question of how to represent it in a dtype.

But the good news is that while we may cause performance loss for the rare users that use the current longdouble, we cannot cause precision regressions.

@NeilGirdhar
Copy link
Contributor Author

NeilGirdhar commented May 30, 2019

@seberg I understand the draw of having this match C's definition of long double, but this is going to cause problems when GPUs start supporting float128. I like the suggestion in #5272 to rename float128 to be float80_96 or float80_128 depending on the platform, and then make float128 the true quadruple precision float. longdouble doesn't fit within numpy's very elegant naming scheme.

@seberg
Copy link
Member

seberg commented May 30, 2019

@NeilGirdhar I was merely thinking we could try to Deprecate or if we already know we can pull of true float128 now Future warn float128, naming it differently, such as float80_96 would seem good (although I am not sure that is correct on Macs? Weren't they double-double users?).

@rgommers
Copy link
Member

@rgommers - some googling suggests both the llwm and the intel compiler also support it, though the latter perhaps not trivially (but presumably we can get some help from the intel folks). Are there other compilers are you thinking about?

MSVC mainly.

@mhvk
Copy link
Contributor

mhvk commented May 30, 2019

Hmm, MSVC status seems rather unclear for quad precision. Though I'm not sure it is better to have a regular double inside a float128, as I gather is the case now according to the numpy docs. cc @eric-wieser in case he knows.

@matthew-brett
Copy link
Contributor

Also - there will be users who have saved e.g. npy files with float128 / float96 type, where float128 is in fact padded float80. If you re-purpose float128, you'll break those files.

@NeilGirdhar
Copy link
Contributor Author

@matthew-brett Can't you just bump the npy version number?

@matthew-brett
Copy link
Contributor

I guess - maybe with some extra code to cast the loaded data to the new types, say float80_128. This just a marker to remind us that we will need those types, and to do those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants