1 // SPDX-License-Identifier: GPL-2.0-only
2 /* IEEE754 floating point arithmetic
3 * double precision: common utilities
6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
10 #include "ieee754sp.h"
11 #include "ieee754dp.h"
13 static inline union ieee754dp ieee754dp_nan_fsp(int xs, u64 xm)
15 return builddp(xs, DP_EMAX + 1 + DP_EBIAS,
16 xm << (DP_FBITS - SP_FBITS));
19 union ieee754dp ieee754dp_fsp(union ieee754sp x)
30 case IEEE754_CLASS_SNAN:
31 return ieee754dp_nanxcpt(ieee754dp_nan_fsp(xs, xm));
33 case IEEE754_CLASS_QNAN:
34 return ieee754dp_nan_fsp(xs, xm);
36 case IEEE754_CLASS_INF:
37 return ieee754dp_inf(xs);
39 case IEEE754_CLASS_ZERO:
40 return ieee754dp_zero(xs);
42 case IEEE754_CLASS_DNORM:
44 while ((xm >> SP_FBITS) == 0) {
50 case IEEE754_CLASS_NORM:
55 * Can't possibly overflow,underflow, or need rounding
58 /* drop the hidden bit */
61 return builddp(xs, xe + DP_EBIAS,
62 (u64) xm << (DP_FBITS - SP_FBITS));