Failed to parse Float from string using playdate->system->parseString

,

Seems like parseString fails to parse floats

i32 a   = 0;
f32 b   = 0;
f64 c   = 0;
i32 res = 0;
res     = PD->system->parseString("990", "%d", &a);
PD->system->logToConsole("%d = %d", a, res);
res = PD->system->parseString("1123.0", "%f", &b);
PD->system->logToConsole("%f = %d", (double)b, res);
res = PD->system->parseString("-123.0", "%lf", &c);
PD->system->logToConsole("%f = %d", c, res);

get's the following result:

990 = 1
0.000000 = 0
0.000000 = 0
3 Likes

I'm seeing this as well. Specifically, it works on the Simulator, but breaks on the Device. I assume the Simulator is just calling through to normal sscanf() and the Device has a custom implementation.

Simple sample:

float my_float;
int match_count = pd->system->parseString("123.456", "%f", &my_float);

Expected: match_count == 1 and my_float == 123.546.
Found on SIMULATOR: match_count == 1 and my_float == 123.546
Found on DEVICE: match_count == 0 and my_float == 0.0
Found with SSCANF() locally: match_count == 1 and my_float == 123.456

Reproducing the error:
I'm attaching a "main.c" that will output the value when dropped into the Hello World project.

main.c.zip (1.2 KB)

That program just has some lines added to the kEventInit event.

Hi! I’m using sscanf and noticed that the parsing is not working on the device, tried with pd->system->parseString but got the same bug. It does work on the simulator.

I’m using the latest SDK (3.0.3).