diff options
author | stijn <stinos@zoho.com> | 2015-05-16 10:54:19 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-17 21:47:11 +0100 |
commit | 861670ba2ad6fe575de4a31c95c01070ed900391 (patch) | |
tree | 4a62df6a4e95183f472a38ee06c4b8729f2d51c1 /py/formatfloat.h | |
parent | f5dd6f7f3707b67acbd1dbfe71cad2b958d5d7be (diff) | |
download | micropython-861670ba2ad6fe575de4a31c95c01070ed900391.tar.gz micropython-861670ba2ad6fe575de4a31c95c01070ed900391.zip |
py: Implement mp_format_float for doubles and use where appropriate
This allows using (almost) the same code for printing floats everywhere,
removes the dependency on sprintf and uses just snprintf and
applies an msvc-specific fix for snprintf in a single place so
nan/inf are now printed correctly.
Diffstat (limited to 'py/formatfloat.h')
-rw-r--r-- | py/formatfloat.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/formatfloat.h b/py/formatfloat.h index 1eb2c1e46f..0196034471 100644 --- a/py/formatfloat.h +++ b/py/formatfloat.h @@ -26,6 +26,10 @@ #ifndef __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ #define __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ -int mp_format_float(float f, char *buf, size_t bufSize, char fmt, int prec, char sign); +#include "py/mpconfig.h" + +#if MICROPY_PY_BUILTINS_FLOAT +int mp_format_float(mp_float_t f, char *buf, size_t bufSize, char fmt, int prec, char sign); +#endif #endif // __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ |