2 Copyright 2018-2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Paul Eggert. */
26 unsigned sign
; unsigned exponent
; unsigned frac
;
27 } const float_tests
[] =
31 {0.1, 0, 0x7b, 0x4ccccd}
36 unsigned sign
; unsigned exponent
; unsigned frac_hi
; unsigned frac_lo
;
37 } const double_tests
[] =
41 {0.1, 0, 0x3fb, 0x99999, 0x9999999a}
49 for (i
= 0; i
< sizeof float_tests
/ sizeof *float_tests
; i
++)
51 union ieee754_float u
;
52 u
.f
= float_tests
[i
].x
;
53 if (float_tests
[i
].sign
!= u
.ieee
.negative
)
55 if (float_tests
[i
].exponent
!= u
.ieee
.exponent
)
57 if (float_tests
[i
].frac
!= u
.ieee
.mantissa
)
61 for (i
= 0; i
< sizeof double_tests
/ sizeof *double_tests
; i
++)
63 union ieee754_double u
;
64 u
.d
= double_tests
[i
].x
;
65 if (double_tests
[i
].sign
!= u
.ieee
.negative
)
67 if (double_tests
[i
].exponent
!= u
.ieee
.exponent
)
69 if (double_tests
[i
].frac_hi
!= u
.ieee
.mantissa0
)
71 if (double_tests
[i
].frac_lo
!= u
.ieee
.mantissa1
)