From 119d5b3125cd7e20d4ec43c069b234ae0ae9b0b9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 14 Sep 2015 13:14:53 -0700 Subject: Describe WebAssembly's C/C++ ABI floating point types. The rationale for making C/C++ long double something other than 64-bit is: - there are use cases for quad-precision floating point types, and "long double" is a friendlier way to satisfy those use cases than extensions like "__float128" since "long double" has the benefit of libm and printf API support. - long double is a lost cause in terms of portable functionality anyway. 64-bit, 80-bit, and 128-bit long double types are in use in popular platforms, so people who want portable results aren't using it. - it's also a lost cause in terms of portable performance, as it's already significantly slower than double on several widely popular platforms, so people who want portable performance already have motivation to avoid it. The rationale for picking quad-precision over double-double is that even though double-double can be significantly faster, it has surprising numeric properties which make it undesirable to impose on unsuspecting code. --- CAndC++.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CAndC++.md b/CAndC++.md index 9429f05..e21309a 100644 --- a/CAndC++.md +++ b/CAndC++.md @@ -22,6 +22,17 @@ has an LP64 data model, meaning that `long` and pointer types will be added in the future to support [64-bit address spaces](FutureFeatures.md#linear-memory-bigger-than-4-gib). +`float` and `double` are the IEEE 754-2008 single- and double-precision types, +which are native in WebAssembly. `long double` is the IEEE 754-2008 +quad-precision type, which is a software-emulated type. WebAssembly does +not have a builtin quad-precision type. Quad-precision is not part of +the WebAssembly platform itself. There are no quad-precision operators +built into WebAssembly. The long double type here is software-emulated +in library code linked into WebAssembly applications that need it. + +For performance and compatibility with other platforms, `float` and +`double` are recommended for most uses. + ### Language Support C and C++ language conformance is largely determined by individual compiler -- cgit v1.2.3