From 7bf92a1ee80c988f736d4f3f1a5a8edbca74456e Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 24 Aug 2009 21:27:30 +0200 Subject: * digital/avr/modules/math/fixed: - round division result (closes #96). - changed macros to inlined. --- digital/avr/modules/math/fixed/test/Makefile | 3 ++- digital/avr/modules/math/fixed/test/test_fixed.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'digital/avr/modules/math/fixed/test') diff --git a/digital/avr/modules/math/fixed/test/Makefile b/digital/avr/modules/math/fixed/test/Makefile index 04aa4cff..17412941 100644 --- a/digital/avr/modules/math/fixed/test/Makefile +++ b/digital/avr/modules/math/fixed/test/Makefile @@ -28,6 +28,7 @@ clean.test: rm -f $(TEST_FILES) SIMULAVR = simulavr -d $(AVR_MCU) -W 0x22,- -R 0x20,- -T uart0_exit +CR2NL = tr '\r' '\n' .PRECIOUS: $(TEST_FILES) @@ -35,4 +36,4 @@ test.%.host: test_fixed.host echo '!$(call code,$@,host)' | ./$< > $@ test.%.simu: test_fixed.avr.simu.elf - echo '!$(call code,$@,simu)\r' | $(SIMULAVR) -f $< > $@ + echo -e '!$(call code,$@,simu)\r' | $(SIMULAVR) -f $< | $(CR2NL) > $@ diff --git a/digital/avr/modules/math/fixed/test/test_fixed.c b/digital/avr/modules/math/fixed/test/test_fixed.c index 875aad4f..cc9a6045 100644 --- a/digital/avr/modules/math/fixed/test/test_fixed.c +++ b/digital/avr/modules/math/fixed/test/test_fixed.c @@ -53,7 +53,7 @@ check_div (int32_t a, int32_t b, int32_t r) feclearexcept (FE_ALL_EXCEPT); double af = (double) a / (1 << 24); double bf = (double) b / (1 << 24); - int32_t ri = af / bf * (1 << 24); + int32_t ri = rint (af / bf * (1 << 24)); if (r != ri && !fetestexcept (FE_INVALID)) printf ("error: %08x / %08x != %08x (%08x)\n", a, b, r, ri); } -- cgit v1.2.3