File tree 2 files changed +42
-7
lines changed
test/floating_point/ultof/src 2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 4
4
5
5
public __ultof
6
6
7
+ if 0
8
+
7
9
; round to nearest ties to even
8
10
__ultof:
9
11
bit 7, a
@@ -26,4 +28,27 @@ __ultof:
26
28
res 0, c
27
29
ret
28
30
31
+ else
32
+
33
+ ; round to nearest ties away from zero (to match __ltof behaviour)
34
+ __ultof:
35
+ bit 7, a
36
+ jp z, __ltof ; common case
37
+ ; A:UBC > INT32_MAX
38
+ res 7, a ; sets the LSB of the exponent
39
+ ; A:UBC >>= 8
40
+ push af
41
+ or a, c ; M = Round
42
+ inc sp
43
+ push bc
44
+ inc sp
45
+ pop bc
46
+ inc sp
47
+ ld a, $4F ; sets the exponent
48
+ ret p ; round down
49
+ inc bc
50
+ ret ; round up (this will not overflow because bit 23 is 0)
51
+
52
+ end if
53
+
29
54
extern __ltof
Original file line number Diff line number Diff line change @@ -37,13 +37,23 @@ size_t run_test(void) {
37
37
result .flt = (float )input [i ];
38
38
if (result .bin != output [i ].bin ) {
39
39
// ignore round to maximum magnitude errors from __ltof
40
- bool ignore_ltof_failure =
41
- (input [i ] <= INT32_MAX ) &&
42
- (result .bin == output [i ].bin + 1 );
43
- if (ignore_ltof_failure == false) {
44
- print_failed (input [i ], result .bin , output [i ].bin );
45
- return i ;
46
- }
40
+ #if 0
41
+ bool ignore_ltof_failure =
42
+ (input [i ] <= INT32_MAX ) &&
43
+ (result .bin == output [i ].bin + 1 );
44
+ if (ignore_ltof_failure == false) {
45
+ print_failed (input [i ], result .bin , output [i ].bin );
46
+ return i ;
47
+ }
48
+ #else
49
+ // round to nearest ties away from zero to match __ltof behaviour
50
+ bool ignore_ltof_failure =
51
+ (result .bin == output [i ].bin + 1 );
52
+ if (ignore_ltof_failure == false) {
53
+ print_failed (input [i ], result .bin , output [i ].bin );
54
+ return i ;
55
+ }
56
+ #endif
47
57
}
48
58
}
49
59
You can’t perform that action at this time.
0 commit comments