ieee-754.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef SCM_IEEE_754_H
  16. #define SCM_IEEE_754_H 1
  17. /* Based on glibc's <ieee754.h> and modified by Ludovic Courtès to include
  18. all possible IEEE-754 double-precision representations. */
  19. /* IEEE 754 simple-precision format (32-bit). */
  20. union scm_ieee754_float
  21. {
  22. float f;
  23. struct
  24. {
  25. unsigned int negative:1;
  26. unsigned int exponent:8;
  27. unsigned int mantissa:23;
  28. } big_endian;
  29. struct
  30. {
  31. unsigned int mantissa:23;
  32. unsigned int exponent:8;
  33. unsigned int negative:1;
  34. } little_endian;
  35. };
  36. /* IEEE 754 double-precision format (64-bit). */
  37. union scm_ieee754_double
  38. {
  39. double d;
  40. struct
  41. {
  42. /* Big endian. */
  43. unsigned int negative:1;
  44. unsigned int exponent:11;
  45. /* Together these comprise the mantissa. */
  46. unsigned int mantissa0:20;
  47. unsigned int mantissa1:32;
  48. } big_endian;
  49. struct
  50. {
  51. /* Both byte order and word order are little endian. */
  52. /* Together these comprise the mantissa. */
  53. unsigned int mantissa1:32;
  54. unsigned int mantissa0:20;
  55. unsigned int exponent:11;
  56. unsigned int negative:1;
  57. } little_little_endian;
  58. struct
  59. {
  60. /* Byte order is little endian but word order is big endian. Not
  61. sure this is very wide spread. */
  62. unsigned int mantissa0:20;
  63. unsigned int exponent:11;
  64. unsigned int negative:1;
  65. unsigned int mantissa1:32;
  66. } little_big_endian;
  67. };
  68. #endif /* SCM_IEEE_754_H */