floatunsisf.c 486 B

12345678910111213141516171819
  1. /* Public domain. */
  2. typedef int SItype __attribute__ ((mode (SI)));
  3. typedef unsigned int USItype __attribute__ ((mode (SI)));
  4. typedef float SFtype __attribute__ ((mode (SF)));
  5. SFtype
  6. __floatunsisf (USItype u)
  7. {
  8. SItype s = (SItype) u;
  9. if (s < 0)
  10. {
  11. /* As in expand_float, compute (u & 1) | (u >> 1) to ensure
  12. correct rounding if a nonzero bit is shifted out. */
  13. return (SFtype) 2.0 * (SFtype) (SItype) ((u & 1) | (u >> 1));
  14. }
  15. else
  16. return (SFtype) s;
  17. }