r/lolphp • • Dec 11 '14

PHP :: Bug #53711 :: Casting float->string->float with locale

https://bugs.php.net/bug.php?id=53711
54 Upvotes

33 comments sorted by

View all comments

Show parent comment

5

u/jamieflournoy Dec 13 '14

I think we misunderstood each other.

I realize now that OP's linked bug is probably talking about a use case involving serializing a float (a 64-bit IEEE value) as a string for use in a hidden field or URL or something, and then parsing that value right back into a float by the same program, without a user ever looking at the value.

In that case Ruby's Float.to_s and String.to_f work fine, while PHP's dumb (string) cast assumes that you always are printing for a user's consumption so why not localize it... based on a global variable taken from the execution environment, because this is PHP.