Rfcs: Should we add f80?

Created on 25 Dec 2017  ·  10Comments  ·  Source: rust-lang/rfcs

Should we add f80? Even if it is not often used.

T-lang T-libs

Most helpful comment

AFAIU support for a type that is compatible with long double in C would not be possible in an external crate, as it needs to be passed in specific ways across function boundaries (depending on the target ABI).
Moreover, f80 is the x86 version of C long double, but other targets behave in a different way (according to https://en.wikipedia.org/wiki/Long_double on SPARC and HP-UX it means f128).

I believe that the main cause for the lack of support in Rust is that long double is not commonly used across language boundaries and there has been little interest in using higher precision floating point numbers in Rust (except maybe through software support).
Some concrete use cases would probably be the first step towards making this issue into a complete RFC.

All 10 comments

I think this issue is under-specified, can you please clarify?

I agree that some more details are definitely needed.
@3442853561 are you looking for a primitive type that is FFI-compatible with long double in C or for higher-precision floating point types?

@ranma42 Yes, I'm looking for a primitive type which like long double in C

We can build it as a crate, however I think it should in stdlib instead of other crate.

So, what should we do now? Should we create a crate for the f80 type first, and talk about it should enter the standard library later?

AFAIU support for a type that is compatible with long double in C would not be possible in an external crate, as it needs to be passed in specific ways across function boundaries (depending on the target ABI).
Moreover, f80 is the x86 version of C long double, but other targets behave in a different way (according to https://en.wikipedia.org/wiki/Long_double on SPARC and HP-UX it means f128).

I believe that the main cause for the lack of support in Rust is that long double is not commonly used across language boundaries and there has been little interest in using higher precision floating point numbers in Rust (except maybe through software support).
Some concrete use cases would probably be the first step towards making this issue into a complete RFC.

@ranma42 Honestly, that to me means that implementing both f80 and f128 could help with implementing a c_longdouble for platforms with IEEE 754 support. Although, that'd also mean implementing f16 for completeness and at that point you really start to wonder if all of this is necessary.

That said, all of these types are rigourously defined, which would technically not rule them out for FFI.

FWIW We have already added architecture-specific types, like the SIMD vector types, to std::arch which is in beta. We could probably exposef80 through std::arch as well on those architectures in which it is available.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3442853561 picture 3442853561  ·  3Comments

clarfonthey picture clarfonthey  ·  3Comments

rudolfschmidt picture rudolfschmidt  ·  3Comments

mahkoh picture mahkoh  ·  3Comments

rust-highfive picture rust-highfive  ·  4Comments