revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-all / arm-aeabi / i2f.c
blob4d6a6078d5dc38a52f4a17eb9ae2a41efddea5c7
1 /*
2 Copyright (C) 2009-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <inttypes.h>
8 uint32_t __aeabi_ui2f(uint32_t val)
10 int exp = 0;
11 uint32_t result = 0;
13 if (val == 0)
14 return 0;
16 exp = __builtin_clz(val);
18 if (exp <= 6)
19 val >>= (7 - exp);
20 else
21 val <<= (exp - 7);
23 if ((val & 1))
25 val ++;
26 if (0x02000000 == val) exp++;
29 val >>= 1;
30 val &= 0x7fffff;
32 exp = 0x7E + 32 - exp;
34 /* adapt Exponent to IEEESP-Format */
35 exp <<= 23;
36 result = val | exp;
38 return result;
41 uint32_t __aeabi_i2f(int32_t val)
43 if (val == 0)
44 return 0;
46 if (val < 0)
47 return 0x80000000 | __aeabi_ui2f((uint32_t)(-val));
48 else
49 return __aeabi_ui2f(val);