You addresses data loss on convert float to int. Do you also address data loss on int to float?
|to_float(||9223372036854774784) -> pass |as it results in 9223372036854774784 |to_float(|||9223372036854774785|) -> |fail as it results in 9223372036854774784 | Marc | On 23.10.2014 21:40, Marc Bennewitz wrote: > I really like the strictness of this casting rules except of "010" will > be a valid integer / float. > As of you don't allow "0x" and trailing white spaces as valid numbers > and don't allow floating like syntax as integers even if it result in > mathematical integer. > > Allowing prefixed "0" as valid numbers results in a small data loss > ("010" !== to_string(to_int("010"))), > is simple to address in user land with ltrim("010", "0") (Same argument > as trailing whitespace) > and collides with octal notation (010 !== to_int("010")) > > Marc > > On 21.10.2014 00:57, Andrea Faulds wrote: >> Good evening, >> >> I am presenting a new RFC to add a set of three functions to do validated >> casts for scalar types: >> >> https://wiki.php.net/rfc/safe_cast >> >> Please read it. >> >> Thanks! >> -- >> Andrea Faulds >> http://ajf.me/ >> >> >> >> >> >