/* IEEE (and related) format descriptions. */
const struct fltfmt_ieeefmt
- fltfmt_mini = { IEEEF_HIDDEN, 4, 4 },
- fltfmt_bf16 = { IEEEF_HIDDEN, 8, 8 },
- fltfmt_f16 = { IEEEF_HIDDEN, 5, 11 },
- fltfmt_f32 = { IEEEF_HIDDEN, 8, 24 },
- fltfmt_f64 = { IEEEF_HIDDEN, 11, 53 },
- fltfmt_f128 = { IEEEF_HIDDEN, 15, 113 },
+ fltfmt_mini = { FLTIF_HIDDEN, 4, 4 },
+ fltfmt_bf16 = { FLTIF_HIDDEN, 8, 8 },
+ fltfmt_f16 = { FLTIF_HIDDEN, 5, 11 },
+ fltfmt_f32 = { FLTIF_HIDDEN, 8, 24 },
+ fltfmt_f64 = { FLTIF_HIDDEN, 11, 53 },
+ fltfmt_f128 = { FLTIF_HIDDEN, 15, 113 },
fltfmt_idblext80 = { 0, 15, 64 };
/* --- @fltfmt_encieee@ ---
/* Determine the output size. */
nb = fmt->prec + fmt->expwd + 1;
- if (fmt->f&IEEEF_HIDDEN) nb--;
+ if (fmt->f&FLTIF_HIDDEN) nb--;
nw = (nb + 31)/32;
/* Determine the top bits. */
*/
z0 |= M32(fmt->expwd) << esh;
- if (!(fmt->f&IEEEF_HIDDEN)) z0 |= B32(esh - 1);
+ if (!(fmt->f&FLTIF_HIDDEN)) z0 |= B32(esh - 1);
} else if (f&FLTF_NANMASK) {
/* Not-a-number.
n = x->n; if (n > mw) n = nw;
t = shr(z + i, x->frac, n, sh); i += n;
if (i < nw) z[i++] = t;
- sh = esh - 2; if (fmt->f&IEEEF_HIDDEN) sh++;
+ sh = esh - 2; if (fmt->f&FLTIF_HIDDEN) sh++;
if (f&FLTF_QNAN) z0 |= B32(sh);
else if (!fracwd) { ERR(FLTERR_INEXACT); z[nw - 1] |= 1; }
/* Set the exponent and, for non-hidden-bit formats, the unit bit. */
z0 |= M32(fmt->expwd) << esh;
- if (!(fmt->f&IEEEF_HIDDEN)) z0 |= B32(esh - 1);
+ if (!(fmt->f&FLTIF_HIDDEN)) z0 |= B32(esh - 1);
} else {
/* A finite value.
* the rounding mode.
*/
+ ERR(FLTERR_OFLOW | FLTERR_INEXACT);
rf = FRPF_ODD | FRPF_HALF | FRPF_LOW;
if (f&FLTF_NEG) rf |= FRPF_NEG;
- if ((r >> rf)&1) {
- ERR(FLTERR_OFLOW | FLTERR_INEXACT);
+ if ((r >> rf)&1)
z0 |= M32(fmt->expwd) << esh;
- } else {
- ERR(FLTERR_INEXACT);
+ else {
z0 |= (B32(fmt->expwd) - 2) << esh;
- mb = fmt->prec; if (fmt->f&IEEEF_HIDDEN) mb--;
+ mb = fmt->prec; if (fmt->f&FLTIF_HIDDEN) mb--;
mw = (mb + 31)/32;
i = nw - mw;
z[i++] = M32(mb%32);
z0 |= (exp + maxexp) << esh;
/* Clear the unit bit if we're suppose to use a hidden-bit convention. */
- if (fmt->f&IEEEF_HIDDEN) {
+ if (fmt->f&FLTIF_HIDDEN) {
mb = fmt->prec - 1; mw = (mb + 31)/32; mb = mb%32;
z[nw - mw] &= ~B32(mb);
}
*/
assert(fmt->expwd + 3 <= 32);
esh = 31 - fmt->expwd; emask = M32(fmt->expwd);
- sigwd = fmt->prec; if (fmt->f&IEEEF_HIDDEN) sigwd--;
+ sigwd = fmt->prec; if (fmt->f&FLTIF_HIDDEN) sigwd--;
/* Determine the input size. */
nb = sigwd + fmt->expwd + 1; nw = (nb + 31)/32;
* Note that we don't include the quiet bit in our decoded payload.
*/
- if (!(fmt->f&IEEEF_HIDDEN)) {
+ if (!(fmt->f&FLTIF_HIDDEN)) {
/* No hidden bit, so we expect the unit bit to be set. If it isn't,
* that's technically invalid, and its absence won't survive a round
* trip, since the bit isn't considered part of a NaN payload -- or
if (ms_set_bit(x + nw, 0, sigwd) == ALLCLEAR)
f |= FLTF_INF;
else {
- sh = esh - 2; if (fmt->f&IEEEF_HIDDEN) sh++;
+ sh = esh - 2; if (fmt->f&FLTIF_HIDDEN) sh++;
if (x0&B32(sh)) f |= FLTF_QNAN;
else f |= FLTF_SNAN;
sigwd--; mw = (sigwd + 31)/32;
* Otherwise, we'll normalize the incoming value regardless, but report
* settings of the unit bit which are inconsistent with the exponent.
*/
- if (fmt->f&IEEEF_HIDDEN) {
+ if (fmt->f&FLTIF_HIDDEN) {
if (!t) { exp = minexp; goto normalize; }
else { exp = t - maxexp; goto hidden; }
} else {