diff --git a/libsane b/libsane index b12ef7b..9c2af7c 160000 --- a/libsane +++ b/libsane @@ -1 +1 @@ -Subproject commit b12ef7bcd2e1ac8cea52a8cef6cef6b2960f143b +Subproject commit 9c2af7c48dcbb58a5af436c295e83643c7f33f8b diff --git a/test/makefile b/test/makefile index 0c5771b..5de27a7 100644 --- a/test/makefile +++ b/test/makefile @@ -46,7 +46,7 @@ clean : # mpw Link $(LDFLAGS) -o $@ $^ $(LIBS) test_sane: o/nan.o o/test_sane.o - $(MPW) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS) + $(MPW) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS) {CLibraries}CSANELib.o % : o/%.o $(MPW) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS) diff --git a/test/test_sane.c b/test/test_sane.c index d77787a..24d2d8e 100644 --- a/test/test_sane.c +++ b/test/test_sane.c @@ -270,6 +270,87 @@ void test_fxc2dec(void) num2dec(&df, 1.0625, &d); dump_decimal(&d); // s/b -6 1062500 +} + +pascal void fp68k_3(void *, void *, unsigned short) = 0xA9EB; + +void test_fx2l(void) { + + long double x; + long int l; + int i; + + static long double data[] = { + 1.25, + 1.5, + 1.75, + 2.25, + 2.5, + 2.75, + -1.25, + -1.5, + -1.75, + -2.25, + -2.5, + -2.75, + }; + + + + + x = inf(); // 1.0 / 0.0; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(inf) = %lx\n", l); + + + x = -inf(); // -1.0 / 0.0; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(-inf) = %lx\n", l); + + x = nan(1); // -1.0 / 0.0; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(nan) = %lx\n", l); + + + x = 1e21; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(1e21) = %lx\n", l); + + x = -1e21; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(-1e21) = %lx\n", l); + + + + setround(UPWARD); + for (i = 0; i < 12; ++i) { + x = data[i]; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(%f) = %ld\n", x, l); + } + setround(DOWNWARD); + for (i = 0; i < 12; ++i) { + x = data[i]; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(%f) = %ld\n", x, l); + } + + setround(TONEAREST); + for (i = 0; i < 12; ++i) { + x = data[i]; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(%f) = %ld\n", x, l); + } + setround(TOWARDZERO); + for (i = 0; i < 12; ++i) { + x = data[i]; + fp68k_3(&x, &l, 0x2810); + printf("fx2l(%f) = %ld\n", x, l); + } + + + + } int main(int argc, char **argv) @@ -293,6 +374,7 @@ int main(int argc, char **argv) test_nan(); test_fxc2dec(); + test_fx2l(); return 0; }