Skip to content

Commit f1696e1

Browse files
committed
Merge pull request #171 from WebAssembly/full-ieee754
Add a FutureFeatures.md section discussing full IEEE-754 conformance.
2 parents ee73a4a + b771579 commit f1696e1

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

AstSemantics.md

+2
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ Floating point arithmetic follows the IEEE-754 standard, except that:
368368
- Not all operations required by IEEE-754 are provided directly. However,
369369
WebAssembly includes enough functionality to support reasonable library
370370
implementations of the remaining required operations.
371+
- The strategy for gradual underflow (subnormals) is
372+
[under discussion](https://github.com/WebAssembly/design/issues/148).
371373

372374
* `float32.add`: addition
373375
* `float32.sub`: subtraction

FutureFeatures.md

+32
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,35 @@ tradeoffs.
301301
* `float32.pow`: exponentiate
302302

303303
The rounding behavior of these operations would need clarification.
304+
305+
## Full IEEE-754 conformance
306+
307+
WebAssembly floating point conforms IEEE-754 in most respects, but there are a
308+
few areas that are [not yet covered](AstSemantics.md#floating-point-operations).
309+
310+
IEEE-754 NaN bit pattern propagation is presently permitted but not required.
311+
It would be possible for WebAssembly to require it in the future.
312+
313+
To support exceptions and alternate rounding modes, one option is to define an
314+
alternate form for each of `add`, `sub`, `mul`, `div`, `sqrt`, and `fma`. These
315+
alternate forms would have extra operands for rounding mode, masked traps, and
316+
old flags, and an extra result for a new flags value. These operations would be
317+
fairly verbose, but it's expected that their use cases will specialized. This
318+
approach has the advantage of exposing no global (even if only per-thread)
319+
control and status registers to applications, and to avoid giving the common
320+
operations the possibility of having side effects.
321+
322+
Debugging techniques are also important, but they don't necessarily need to be
323+
in the spec itself. Implementations are welcome (and encouraged) to support
324+
non-standard execution modes, enabled only from developer tools, such as modes
325+
with alternate rounding, or evaluation of floating point expressions at greater
326+
precision, to support [techniques for detecting numerical instability]
327+
(http://www.cs.berkeley.edu/~wkahan/Mindless.pdf).
328+
329+
To help developers find the sources of floating point exceptions,
330+
implementations may wish to provide a mode where NaN values are produced with
331+
payloads containing identifiers helping programmers locate where the NaNs first
332+
appeared. Another option would be to offer another non-standard execution mode,
333+
enabled only from developer tools, that would enable traps on selected floating
334+
point exceptions, however care should be taken, since not all floating point
335+
exceptions indicate bugs.

0 commit comments

Comments
 (0)