Commit Graph
10 Commits
Author SHA1 Message Date
Thomas WatsonandJasonMDavey f7cde8bf59 AP_HAL: fix ftoa_engine hang with very small floats
Subnormal floats with mantissas of 7 or less (14 before the previous
fix) have less digits to format than the conversion loop expects,
causing it to never meet the condition to exit and looping forever. This
cannot occur with normal floats because the implicit leading 1 always
produces a sufficiently large value to format.

This causes a hang with the 12 floats closest to zero (26 before the
previous fix) if a suitably large precision is passed (which it is by
default using e.g. `%f`). Fix by exiting the conversion loop if we get
in the case where we can't add any more digits.

Co-authored-by: JasonMDavey <65718912+JasonMDavey@users.noreply.github.com>
2025-07-29 16:35:03 +09:00
Thomas Watson 251dca81ff AP_HAL: fix ftoa_engine formatting of subnormal values as 1/2 truth
Subnormal values were formatted as 1/2 of their true value because it
was assumed the mantissa's significance corresponded to an exponent of
0, not the correct exponent of 1 (which represents 2x the value). Fix by
setting the correct exponent in this case.

This affects the ~16.7 million floats closest to zero.
2025-07-29 16:35:03 +09:00
Mykhailo Kuznietsov cc2e156888 AP_HAL: Fix some typos
Fixed some typos found in the code.
2023-10-12 18:30:42 +11:00
Lucas De Marchi 29ed01189d AP_HAL: ftoa_engine: replace tabs with spaces 2015-12-27 15:58:12 -02:00
Lucas De Marchi e751d632e6 AP_HAL: ftoa_engine: stop using Progmem.h 2015-12-27 15:58:12 -02:00
Lucas De Marchi 5244559010 Minimize AP_Progmem.h includes
Most of AP_Progmem is already gone so we can stop including it in most
of the places. The only places that need it are the ones using
pgm_read_*() APIs.

In some cases the header needed to be added in the .cpp since it was
removed from the .h to reduce scope. In those cases the headers were
also reordered.
2015-10-30 14:35:32 +09:00
Lucas De Marchi 1b07dabeb7 Replace prog_char and prog_char_t with char
prog_char and prog_char_t are now the same as char on supported
platforms. So, just change all places that use them and prefer char
instead.

AVR-specific places were not changed.
2015-10-30 14:35:30 +09:00
Lucas De Marchi 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +09:00
Gustavo Jose de Sousa 0456eccca8 AP_HAL: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:43 +10:00
Andrew Tridgell 60122f9877 AP_HAL: moved printf implementation from AP_HAL_AVR to AP_HAL
this gives a common printf implementation on all boards, which
simplifies testing, and also simplifies porting to new boards
2013-09-21 13:28:46 +10:00