unknown italian syntex

hi, i came across this fine code over at the Italian side of the forum.
it compiles (when u add setup and loop) but one line of code looks strange.
can someone decypher this?

 dst = (0.5L*((float)analogRead( PIN_ST )))/10; //lettura in volt

17th line of code in the second code box, original poster is kokiua
0.5L ?
(float)analogRead(x) ?

0.5L == 0.5 as a double precision value.
(float) analogRead(x) == cast the result of analogRead(x) to a floating point value.

Am I being dumb???

It seems that....

dst = (0.5L*((float)analogRead( PIN_ST )))/10; //lettura in volt

... is just scaling something read from "PIN_ST"

Why not the following? (It could, of course, all be collapsed into a single line...

dst= float(analogRead( PIN_ST )/2);
dst= dst/10;

Why turn the value real and then multiply by 0.5? Why not just divide the integer by 2?

For that matter, Why do two calculations? Why not just....

dst= float(analogRead( PIN_ST )/20;

...?

And was...

dst= ... ((float)analogRead...

... just a typo? Should't the ) after float be a ( ?

Puzzled! Anxious to learn!

float used in this way is not a function, it's a cast.

float(foo);    // BAD - call float as if it is a function.

(float) foo;   // GOOD - convert foo's value (presumably an int) to a floating-point value for the duration of this expression.

As to your other point, yes, the entire expression could be re-written as a cast-to-float divided by 20. There's presumably a belief that multiplying is a faster operation than division, but a decent compiler should do the best thing in any case.

That said, 0.5 * x / 10 may be more documentary code than x / 20 (those numbers look fairly magic either way, however).

float(foo);    // BAD - call float as if it is a function.

Except apparently that's what the new release 0011 enables...

--Phil.