Elm Exactly

Figuredynamic-basis-float

Figure 50, APPLY\APPLY on Floats: Arithmetic, in Section D.4.2 Floating-Point Arithmetic.

APPLY(negate,x) = {NaN}if x is NaN = {(−1)⋅x}otherwiseAPPLY(add,x,y) = {NaN}if x or y is NaN,  or {x,y}={+∞,−∞} = {x}if x∈{+∞,−∞} = {y}if y∈{+∞,−∞} = {−0}if x and y are both −0 = {fl(x+y)}otherwiseAPPLY(sub,x,y) = APPLY(add,x,z)where APPLY(negate,y)={z}APPLY(mul,x,y) = {NaN}if x or y is NaN,  or one is a zero and one an infinity = {sgn(x)sgn(y)⋅∞}if x or y is an infinity = {sgn(x)sgn(y)⋅0}if x or y is a zero = {fl(x⋅y)}otherwiseAPPLY(fdiv,x,y) = {NaN}if x or y is NaN,  or both are zeros, or both infinities = {sgn(x)sgn(y)⋅∞}if x is an infinity, or y a zero = {sgn(x)sgn(y)⋅0}if x is a zero, or y an infinity = {fl(x/y)}otherwiseAPPLY(sqrt,x) = {NaN}if x is NaN, or x<0 = {x}if x∈{+0,−0,+∞} = {fl(x)}otherwise \begin{array}{rcll} \APPLY(\kw{negate},x) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{is}\ \dbNaN\\ {\ }& = {\ }& \{(-1)\cdot x\} {\quad}& \text{otherwise}\\[1ex] \APPLY(\kw{add},x,y) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is}\ \dbNaN,\\ {\ }& {\ }& {\quad}& \text{or}\ \{x,y\}=\{+\infty,-\infty\}\\ {\ }& = {\ }& \{x\} {\quad}& \text{if}\ x\in\{+\infty,-\infty\}\\ {\ }& = {\ }& \{y\} {\quad}& \text{if}\ y\in\{+\infty,-\infty\}\\ {\ }& = {\ }& \{-0\} {\quad}& \text{if}\ x\ \text{and}\ y\ \text{are both}\ -0\\ {\ }& = {\ }& \{\dbfl(x+y)\} {\quad}& \text{otherwise}\\[1ex] \APPLY(\kw{sub},x,y) {\ }& = {\ }& \APPLY(\kw{add},x,z) {\quad}& \text{where}\ \APPLY(\kw{negate},y)=\{z\}\\[1ex] \APPLY(\kw{mul},x,y) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is}\ \dbNaN,\\ {\ }& {\ }& {\quad}& \text{or one is a zero and one an infinity}\\ {\ }& = {\ }& \{\dbsgn(x)\dbsgn(y)\cdot\infty\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is an infinity}\\ {\ }& = {\ }& \{\dbsgn(x)\dbsgn(y)\cdot 0\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is a zero}\\ {\ }& = {\ }& \{\dbfl(x\cdot y)\} {\quad}& \text{otherwise}\\[1ex] \APPLY(\kw{fdiv},x,y) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is}\ \dbNaN,\\ {\ }& {\ }& {\quad}& \text{or both are zeros, or both infinities}\\ {\ }& = {\ }& \{\dbsgn(x)\dbsgn(y)\cdot\infty\} {\quad}& \text{if}\ x\ \text{is an infinity,}\ \text{or}\ y\ \text{a zero}\\ {\ }& = {\ }& \{\dbsgn(x)\dbsgn(y)\cdot 0\} {\quad}& \text{if}\ x\ \text{is a zero,}\ \text{or}\ y\ \text{an infinity}\\ {\ }& = {\ }& \{\dbfl(x/y)\} {\quad}& \text{otherwise}\\[1ex] \APPLY(\kw{sqrt},x) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{is}\ \dbNaN,\ \text{or}\ x<0\\ {\ }& = {\ }& \{x\} {\quad}& \text{if}\ x\in\{+0,-0,+\infty\}\\ {\ }& = {\ }& \{\dbfl(\sqrt{x})\} {\quad}& \text{otherwise} \end{array}
APPLY(isNaN,x) = {True}if x is NaN = {False}otherwiseAPPLY(isInfinite,x) = {True}if x∈{+∞,−∞} = {False}otherwise \begin{array}{rcll} \APPLY(\kw{isNaN},x) {\ }& = {\ }& \{\kw{True}\} {\quad}& \text{if}\ x\ \text{is}\ \dbNaN\\ {\ }& = {\ }& \{\kw{False}\} {\quad}& \text{otherwise}\\[1ex] \APPLY(\kw{isInfinite},x) {\ }& = {\ }& \{\kw{True}\} {\quad}& \text{if}\ x\in\{+\infty,-\infty\}\\ {\ }& = {\ }& \{\kw{False}\} {\quad}& \text{otherwise} \end{array}
Figure 50: APPLY\APPLY on Floats: Arithmetic
Read it in its chapter·Permanent address: /standard/figures/dynamic-basis-float

Referred to from

Tests (0)

No test of the suite checks this figure yet.

Discussions

Discuss this figure·Search the discussions on GitHub

Discussions are on GitHub; one about this figure has [fig:dynamic-basis-float] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.