@@ -6,10 +6,25 @@ SUITE( fbc_tests.numbers.infnan )
66 ''
77 '' Double
88 ''
9+ const SGNMASK = &h7FFFFFFFFFFFFFFFul l
10+ const POSINFD = &h7FF0000000000000ul l
11+ const NEGINFD = &hFFF0000000000000ul l
12+ const POSNAND = &h7FF8000000000000ul l
13+ const NEGNAND = &hFFF8000000000000ul l
914
1015 #macro checkD( d, x )
11- '' Little-endian assumption
12- CU_ASSERT( *cptr( ulongint ptr, @d ) = x )
16+ ' The sign bit for NaN results is unspecified by IEEE754,
17+ ' and x86 and ARM differ in its selection.
18+ '' Little-endian assumption casting double ptr to ulongint ptr
19+ #ifdef __FB_ARM__
20+ # if ( (x = NEGNAND) or (x = POSNAND) )
21+ CU_ASSERT( ((*cptr( ulongint ptr, @d )) and SGNMASK) = POSNAND )
22+ # else
23+ CU_ASSERT( *cptr( ulongint ptr, @d ) = x )
24+ # endif
25+ # else
26+ CU_ASSERT( *cptr( ulongint ptr, @d ) = x )
27+ # endif
1328 #endmacro
1429
1530 #macro checkConstD( N, x )
@@ -36,11 +51,6 @@ SUITE( fbc_tests.numbers.infnan )
3651 end scope
3752 #endmacro
3853
39- const POSINFD = &h7FF0000000000000ul l
40- const NEGINFD = &hFFF0000000000000ul l
41- const POSNAND = &h7FF8000000000000ul l
42- const NEGNAND = &hFFF8000000000000ul l
43-
4454 checkConstD( ( 0.0 / 0 . 0 ), NEGNAND )
4555 checkConstD( ( 0.0 / - 0 . 0 ), NEGNAND )
4656 checkConstD( (- 0.0 / 0 . 0 ), NEGNAND )
@@ -69,15 +79,8 @@ SUITE( fbc_tests.numbers.infnan )
6979 end scope
7080 #endmacro
7181
72- ' The sign bit for NaN results is unspecified by IEEE754,
73- ' and x86 and ARM differ in its selection.
74- #ifdef __FB_ARM__
75- checkVarDivD( 0.0 , 0 . 0 , POSNAND )
76- checkVarDivD( 0.0 , - 0 . 0 , POSNAND )
77- # else
78- checkVarDivD( 0.0 , 0 . 0 , NEGNAND )
79- checkVarDivD( 0.0 , - 0 . 0 , NEGNAND )
80- # endif
82+ checkVarDivD( 0.0 , 0 . 0 , NEGNAND )
83+ checkVarDivD( 0.0 , - 0 . 0 , NEGNAND )
8184 checkVarDivD( - 0.0 , 0 . 0 , NEGNAND )
8285 checkVarDivD( - 0.0 , - 0 . 0 , NEGNAND )
8386 checkVarDivD( 1.0 , 0 . 0 , POSINFD )
@@ -95,13 +98,8 @@ SUITE( fbc_tests.numbers.infnan )
9598 end scope
9699 #endmacro
97100
98- #ifdef __FB_ARM__
99- checkVarDivNegD( 0.0 , 0 . 0 , NEGNAND )
100- checkVarDivNegD( 0.0 , - 0 . 0 , NEGNAND )
101- # else
102- checkVarDivNegD( 0.0 , 0 . 0 , POSNAND )
103- checkVarDivNegD( 0.0 , - 0 . 0 , POSNAND )
104- # endif
101+ checkVarDivNegD( 0.0 , 0 . 0 , POSNAND )
102+ checkVarDivNegD( 0.0 , - 0 . 0 , POSNAND )
105103 checkVarDivNegD( - 0.0 , 0 . 0 , POSNAND )
106104 checkVarDivNegD( - 0.0 , - 0 . 0 , POSNAND )
107105 checkVarDivNegD( 1.0 , 0 . 0 , NEGINFD )
@@ -115,9 +113,25 @@ SUITE( fbc_tests.numbers.infnan )
115113 '' Single
116114 ''
117115
116+ const SGNMASK = &h7FFFFFFF u
117+ const POSINFF = &h7F800000 u
118+ const NEGINFF = &hFF800000 u
119+ const POSNANF = &h7FC00000 u
120+ const NEGNANF = &hFFC00000 u
121+
118122 #macro checkF( f, x )
119- '' Little-endian assumption
120- CU_ASSERT( *cptr( ulong ptr, @f ) = x )
123+ ' The sign bit for NaN results is unspecified by IEEE754,
124+ ' and x86 and ARM differ in its selection.
125+ '' Little-endian assumption casting double ptr to ulongint ptr
126+ #ifdef __FB_ARM__
127+ # if ( (x = NEGNANF) or (x = POSNANF) )
128+ CU_ASSERT( ((*cptr( ulong ptr, @f )) and SGNMASK) = POSNANF )
129+ # else
130+ CU_ASSERT( *cptr( ulong ptr, @f ) = x )
131+ # endif
132+ # else
133+ CU_ASSERT( *cptr( ulong ptr, @f ) = x )
134+ # endif
121135 #endmacro
122136
123137 #macro checkConstF( N, x )
@@ -144,11 +158,6 @@ SUITE( fbc_tests.numbers.infnan )
144158 end scope
145159 #endmacro
146160
147- const POSINFF = &h7F800000 u
148- const NEGINFF = &hFF800000 u
149- const POSNANF = &h7FC00000 u
150- const NEGNANF = &hFFC00000 u
151-
152161 checkConstF( ( 0.0f / 0.0f ), NEGNANF )
153162 checkConstF( ( 0.0f / - 0.0f ), NEGNANF )
154163 checkConstF( (- 0.0f / 0.0f ), NEGNANF )
@@ -177,13 +186,8 @@ SUITE( fbc_tests.numbers.infnan )
177186 end scope
178187 #endmacro
179188
180- #ifdef __FB_ARM__
181- checkVarDivF( 0.0f , 0.0f , POSNANF )
182- checkVarDivF( 0.0f , - 0.0f , POSNANF )
183- # else
184- checkVarDivF( 0.0f , 0.0f , NEGNANF )
185- checkVarDivF( 0.0f , - 0.0f , NEGNANF )
186- # endif
189+ checkVarDivF( 0.0f , 0.0f , NEGNANF )
190+ checkVarDivF( 0.0f , - 0.0f , NEGNANF )
187191 checkVarDivF( - 0.0f , 0.0f , NEGNANF )
188192 checkVarDivF( - 0.0f , - 0.0f , NEGNANF )
189193 checkVarDivF( 1.0f , 0.0f , POSINFF )
@@ -201,13 +205,8 @@ SUITE( fbc_tests.numbers.infnan )
201205 end scope
202206 #endmacro
203207
204- #ifdef __FB_ARM__
205- checkVarDivNegF( 0.0f , 0.0f , NEGNANF )
206- checkVarDivNegF( 0.0f , - 0.0f , NEGNANF )
207- # else
208- checkVarDivNegF( 0.0f , 0.0f , POSNANF )
209- checkVarDivNegF( 0.0f , - 0.0f , POSNANF )
210- # endif
208+ checkVarDivNegF( 0.0f , 0.0f , POSNANF )
209+ checkVarDivNegF( 0.0f , - 0.0f , POSNANF )
211210 checkVarDivNegF( - 0.0f , 0.0f , POSNANF )
212211 checkVarDivNegF( - 0.0f , - 0.0f , POSNANF )
213212 checkVarDivNegF( 1.0f , 0.0f , NEGINFF )
0 commit comments