From b8fbc357931e07373faaff1f22f2b7d6ff0b4f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 18 Jun 2018 15:41:55 +0200 Subject: [PATCH] [emscripten] Fix float rouding errors when computing grid axis labels Emscripten converts C++ floats to doubles, which produces rounding errors. In the Graph application, when displaying y=sin(x), the ordinate '1' displayed "10" instead, because the exponent of 1000f was wrongly computed. To prevent this, we add the -s PRECISE_F32=1 flag, which uses 32-bits floating point values for floats. See https://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html#why-do-i-get-odd-rounding-errors-when-using-float-variables --- build/toolchain.emscripten.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/toolchain.emscripten.mak b/build/toolchain.emscripten.mak index 8b7c2f1bb..d48cc3b01 100644 --- a/build/toolchain.emscripten.mak +++ b/build/toolchain.emscripten.mak @@ -71,7 +71,7 @@ _mp_import_name \ _mp_parse_compile_execute EMTERPRETIFY_WHITELIST = $(foreach sym,$(EMSCRIPTEN_ASYNC_SYMBOLS),"$(sym)",)END -EMFLAGS = -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s EMTERPRETIFY_WHITELIST='[$(EMTERPRETIFY_WHITELIST:,END=)]' +EMFLAGS = -s PRECISE_F32=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s EMTERPRETIFY_WHITELIST='[$(EMTERPRETIFY_WHITELIST:,END=)]' ifeq ($(DEBUG),1) EMFLAGS += --profiling-funcs