summaryrefslogtreecommitdiff
path: root/py/formatfloat.c
AgeCommit message (Collapse)Author
2017-08-21py/formatfloat: Don't post-increment variable that won't be used again.Damien George
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-07-19all: Remove trailing spaces, per coding conventions.Damien George
2017-07-07py,extmod: Some casts and minor refactors to quiet compiler warnings.Tom Collins
2017-06-13py/formatfloat: Fix number of digits and exponent sign when rounding.Damien George
This patch fixes 2 things when printing a floating-point number that requires rounding up of the mantissa: - retain the correct precision; eg 0.99 becomes 1.0, not 1.00 - if the exponent goes from -1 to 0 then render it as +0, not -0
2017-01-19py/formatfloat: Remove unreachable code.Damien George
The if-block that this unreachable code is in has a condition "f>=5" so "fp_isless1(f)" will always fail.
2016-03-29py/formatfloat: Fix further cases of buffer overflow in formatting.Damien George
Includes extensive test cases to catch hopefully all cases where buffer might overflow.
2016-03-29py/formatfloat: Fix case of float format where leading digit was "10".Damien George
When taking the logarithm of the float to determine the exponent, there are some edge cases that finish the log loop too large. Eg for an input value of 1e32-epsilon, this is actually less than 1e32 from the log-loop table and finishes as 10.0e31 when it should be 1.0e32. It is thus rendered as :e32 (: comes after 9 in ascii). There was the same problem with numbers less than 1.
2016-03-15py/formatfloat: Fix buffer overflow when formatting tiny numbers.Damien George
2016-01-29py/formatfloat: Add ability to format doubles with exponents > 99.Damien George
For single prec, exponents never get larger than about 37. For double prec, exponents can be larger than 99 and need 3 bytes to format. This patch makes the number of bytes needed configurable. Addresses issue #1772.
2015-11-22py/formatfloat: Handle calculation of integer digit for %f format properly.Paul Sokolovsky
%f prints true integer digit, so its calculation should happen before any exponential scaling.
2015-11-22py/formatfloat: Workaround (fix?) incorrect rounding for %f format.Paul Sokolovsky
2015-11-22py/formatfloat: Convert to fully portable implementation.Paul Sokolovsky
This takes previous IEEE-754 single precision float implementation, and converts it to fully portable parametrizable implementation using C99 functions like signbit(), isnan(), isinf(). As long as those functions are available (they can be defined in adhoc manner of course), and compiler can perform standard arithmetic and comparison operations on a float type, this implementation will work with any underlying float type (including types whose mantissa is larger than available intergral integer type).
2015-09-11stmhal: fix single precision float printing errorDave Hylands
Fixes #1435.
2015-05-17py: Implement mp_format_float for doubles and use where appropriatestijn
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.
2015-04-12py/formatfloat.c: Fix format of floating point numbers near 1.0.Dave Hylands
In particular, numbers which are less than 1.0 but which round up to 1.0. This also makes those numbers which round up to 1.0 to print with e+00 rather than e-00 for those formats which print exponents. Addresses issue #1178.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-07-17formatfloat.c: Typo fix in comment.Paul Sokolovsky
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-04-01Enhance str.format supportDave Hylands
This adds support for almost everything (the comma isn't currently supported). The "unspecified" type with floats also doesn't behave exactly like python. Tested under unix with float and double Spot tested on stmhal
2014-03-17py: Clean up includes.xbe
Remove unnecessary includes. Add includes that improve portability.
2014-03-10Rename formatfloat file; remove MICROPY_ENABLE_FLOAT from mpconfigport.h.Damien George
MICROPY_ENABLE_FLOAT is automatically set in mpconfig.h if MICROPY_FLOAT_IMPL is set to a non-zero value.