0.5 is read as 0.5 but .5 is read as 5.0 - why

Hi

This is bugging me a little, I am trying to enter a decimal number into my program via the serial port.

If I enter, say 0.5 this is read as 0.5 but if I enter .5 then it is read as 5.0.

I assume I am being dumb here and should probably be using different input code.

float stepsize=0.0; // step size

Serial.print ("Enter step size mm [x.x]");
  while (Serial.available() <= 0) {}
  stepsize = Serial.parseFloat();
  Serial.print(" ...");
  Serial.print(stepsize, 2);
  Serial.println(" mm");

any suggestions most welcome providing they are legal and not offensive and are kept sensible as I am just getting to grips with coding and a lot of what I read just goes over my head ATT.

Regards… Colin

I assume I am being dumb here and should probably be using different input code.

No, and yes.There appears to be a bug in parseFloat(), but you shouldn't be using that anyway.

This forum has only legal, friendly and helpful members, although some can be a little sarcastic.
If you have a serious problem with a reply, you can notify the moderator and they will fix it.

The problem is the way the Serial.parseFloat is written:

Everything that is not a digit (and not a '-') is skipped.

If you want to enter ".5", you have to write your own function to read the incoming Serial data.