// SPDX-License-Identifier: GPL-2.0-only1/* IEEE754 floating point arithmetic2* double precision: common utilities3*/4/*5* MIPS floating point support6* Copyright (C) 1994-2000 Algorithmics Ltd.7*/89#include "ieee754dp.h"1011union ieee754dp ieee754dp_fint(int x)12{13u64 xm;14int xe;15int xs;1617ieee754_clearcx();1819if (x == 0)20return ieee754dp_zero(0);21if (x == 1 || x == -1)22return ieee754dp_one(x < 0);23if (x == 10 || x == -10)24return ieee754dp_ten(x < 0);2526xs = (x < 0);27if (xs) {28if (x == (1 << 31))29xm = ((unsigned) 1 << 31); /* max neg can't be safely negated */30else31xm = -x;32} else {33xm = x;34}3536/* normalize - result can never be inexact or overflow */37xe = DP_FBITS;38while ((xm >> DP_FBITS) == 0) {39xm <<= 1;40xe--;41}42return builddp(xs, xe + DP_EBIAS, xm & ~DP_HIDDEN_BIT);43}444546