sprintf a float
Kaliciak, Richard
hw.kaliciak na fn.de
Úterý Září 13 23:49:21 CEST 2022
Dobry vecer,
ak sa jedna o AVR, tak v mojom makefile mam toto:
# Additional libraries
# Minimalistic printf version
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
# Floating point printf version (requires -lm below)
LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
# By default, all the conversions described above are available except
the floating-point
# conversions and the width is limited to 255 characters. The
float-point conversion will
# be available in the extended version provided by the library
libscanf_flt.a. Also
# in this case the width is not limited (exactly, it is limited to 65535
characters). To link a
# program against the extended version, use the following compiler flags
in the link stage:
#LDFLAGS += -Wl,-u,vfscanf -lscanf_flt
# -lm = math library
LDFLAGS += -lm
Prilinkujte si kniznicu -lprintf_flt
Richard Kaliciak
Dňa 13.09.2022 o 22:01 Petr Zapadlo napísal(a):
> Zdravím,
>
> nějak tady bojuju s sprintf funkcí:
>
> void UART_float(float hodnota){
> char retezec[9];
> sprintf(retezec,"%f",double(hodnota));
>
> UART_puts(retezec);
> }
>
> strašně jednoduchá funkce, cílem je dostat float na výstup UARTu.
> Problém je v tom, že mi to vrátí jen otazník ?.
>
> Když tam dám int /uint nebo jakýkoliv celočíselný typ, tak to funguje
> podle předpokladů, ale já bych potřeboval právě ten float.
>
> Jak na to?
>
> Díky
>
> Petr
>
> _______________________________________________
> HW-list mailing list - sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list
Další informace o konferenci Hw-list