phoenix-rtos / phoenix-rtos-project

Sample project using Phoenix-RTOS
https://phoenix-rtos.com
BSD 3-Clause "New" or "Revised" License
45 stars 32 forks source link

`strtod()`, `strtof()`, `strtold()` doesn't convert correctly hexadecimal value from string #703

Closed mateusz-bloch closed 4 months ago

mateusz-bloch commented 1 year ago

When the string to be converted by strtod(), strtof(), strtold() has a hexadecimal value, the conversion does not proceed correctly

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    char str[] = "0X1.FFFFFEP-127";
    float strtof_output = strtof(str, NULL);
    double strtod_output = strtod(str, NULL);
    long double strtold_output = strtold(str, NULL);

    printf("%f\n", strtof_output);
    printf("%lf\n", strtod_output);
    printf("%Lf\n", strtold_output);

    return 0;
}

image

image

Darchiv commented 4 months ago

Duplicate of https://github.com/phoenix-rtos/phoenix-rtos-project/issues/657