1 /* Bitwise manipulation over float. Function prototypes.
2 Copyright (C) 2011-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _FLOAT_BITWISE_
21 #define _FLOAT_BITWISE_ 1
23 #include <math_private.h>
25 /* Returns (int)(num & 0x7FFFFFF0 == value) */
27 __float_and_test28 (float num
, float value
)
34 } mask
= { .i
= 0x7ffffff0 };
36 /* the 'f' constraint is used on mask because we just need
37 * to compare floats, not full vector */
38 "xxland %x0,%x1,%x2" : "=f" (ret
) : "f" (num
), "f" (mask
.f
)
42 GET_FLOAT_WORD(inum
, num
);
43 inum
= (inum
& 0x7ffffff0);
44 SET_FLOAT_WORD(ret
, inum
);
46 return (ret
== value
);
49 /* Returns (int)(num & 0x7FFFFF00 == value) */
51 __float_and_test24 (float num
, float value
)
58 } mask
= { .i
= 0x7fffff00 };
60 "xxland %x0,%x1,%x2" : "=f" (ret
) : "f" (num
), "f" (mask
.f
)
64 GET_FLOAT_WORD(inum
, num
);
65 inum
= (inum
& 0x7fffff00);
66 SET_FLOAT_WORD(ret
, inum
);
68 return (ret
== value
);
71 /* Returns (float)(num & 0x7F800000) */
73 __float_and8 (float num
)
80 } mask
= { .i
= 0x7f800000 };
82 "xxland %x0,%x1,%x2" : "=f" (ret
) : "f" (num
), "f" (mask
.f
)
86 GET_FLOAT_WORD(inum
, num
);
87 inum
= (inum
& 0x7f800000);
88 SET_FLOAT_WORD(ret
, inum
);
93 /* Returns ((int32_t)(num & 0x7F800000) >> 23) */
95 __float_get_exp (float num
)
103 } mask
= { .i
= 0x7f800000 };
105 "xxland %x0,%x1,%x2" : "=f" (ret
) : "f" (num
), "f" (mask
.f
)
107 GET_FLOAT_WORD(inum
, ret
);
109 GET_FLOAT_WORD(inum
, num
);
110 inum
= inum
& 0x7f800000;
115 #endif /* s_float_bitwise.h */