![]() |
float()
Can anyone tell me if this is supposed to happen and if so, why?
PHP Code:
|
This is known behavior, and I think intentional (would need to contact Stefan for reasoning). It shouldn't be hard to make your own float function which calls the internal float only in the case where all the characters of the string are integers (or decimal points). Not sure about scientific notation and how it handles that.
|
Well this is just silly.
PHP Code:
|
Quote:
|
Quote:
|
Quote:
|
int("123str") should really return -1 too
|
Quote:
|
Quote:
|
This is the same behaviour as the various C functions for converting a string to integer or floating point value.
|
Quote:
|
Why the hell does Stefan have to do all the programming for you infants
stefan can you add a function to tie my shoelaces :'( |
Quote:
|
Quote:
|
Quote:
|
Quote:
Stefan is earning money with graal, we are paying him to play, and develop on it. Something is not working as expected, they ask for a change, it is their right to ask stefan to change it for them, and not spend both their time own time on it. You were asking why stefan had to do all the programming, not why he should or should not change float(). |
We don't pay anyone. We rent their service to continue their work. We're more or so donaters, not tax payers so why should Stefan be expected to make anything more than he has to other than player satisfaction?
|
Quote:
|
For what it's worth, I've never used a float() function that didn't convert "123str" into 123. That's kind of the purpose, isn't it?
|
Quote:
PHP Code:
If this is a problem then you should validate your input before processing. |
Call me stupid but what are some actual purpose of using float( "123str");
|
Quote:
|
Quote:
|
Skyld is my hero.
|
Quote:
I also don't think it matters that this is "how it usually works" in dynamically-typed languages, since a lot of other languages do dumb things. But the important fact is that this behavior already exists and bugs may be introduced if it is changed. |
In my opinion, the fact that float returns -1 on error makes less sense then "123str" returning 123.
|
Quote:
Edit: Post 666 |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 12:05 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.