dos.library: Even m68k can have DEVICES: now!
[AROS.git] / arch / arm-all / arm-aeabi / l2f.c
blob3588d64e988a6dca53c61835c5eee1dc0de2f9d6
1 /*
2 Copyright (C) 2009-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <inttypes.h>
8 uint32_t __aeabi_ul2f(uint64_t val)
10 int exp = 0;
11 uint32_t result = 0;
12 uint32_t v = 0;
14 if (val == 0)
15 return 0;
17 exp = 64 - __builtin_clzl(val);
19 if (exp >= 26)
20 v = (uint32_t)(val >> (exp - 25));
21 else
22 v = (uint32_t)(val << (25 - exp));
24 if ((v & 1))
26 v ++;
27 if (0x02000000 == v) exp++;
30 result = (v >> 1) & 0x7fffff;
32 exp += 0x7E;
34 /* adapt Exponent to IEEESP-Format */
35 exp <<= 23;
36 result |= exp;
38 return result;
41 uint32_t __aeabi_l2f(int64_t val)
43 if (val == 0)
44 return 0;
45 else if (val < 0)
46 return 0x80000000 | __aeabi_ul2f((uint64_t)(-val));
47 else
48 return __aeabi_ul2f(val);