[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
This commit is contained in:
Léa Saviot
2018-06-18 15:41:55 +02:00
committed by Ecco
parent 4a7e4ee512
commit b8fbc35793

View File

@@ -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