File tree Expand file tree Collapse file tree 2 files changed +42
-7
lines changed
test/floating_point/ultof/src Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 44
55 public __ultof
66
7+ if 0
8+
79; round to nearest ties to even
810__ultof:
911 bit 7, a
@@ -26,4 +28,27 @@ __ultof:
2628 res 0, c
2729 ret
2830
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+
2954 extern __ltof
Original file line number Diff line number Diff line change @@ -37,13 +37,23 @@ size_t run_test(void) {
3737 result .flt = (float )input [i ];
3838 if (result .bin != output [i ].bin ) {
3939 // 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
4757 }
4858 }
4959
You can’t perform that action at this time.
0 commit comments