Hi Community,
printf() (and variants) fail on rounding floats: This is is probably an error in the printf implementation. I tested it with SDK 16.0 on NRF52840.
Format String "%.1f" with argument "0.95" should print "1.0" (or at least "0.9"), but the rsult is "0.:".
It would be nice to have this working.
Best regards,
Jo
// Test function:
case 'z':
{
float fval;
fval=atof(input+1);
printf("Fval: '%.1f'\n",fval);
}
break;
...
// OUTPUT:
>z0.9
Fval: '0.9'
>z0.94
Fval: '0.9'
>z0.95
Fval: '0.:' <---- ??? Rounding Error (ASCII ':' follows '9')
>z0.96
Fval: '1.0'
>z1.2345
Fval: '1.2'
>z1.25
Fval: '1.2'