Re: [RFC] Safe Casting Functions

From: Date: Thu, 23 Oct 2014 23:53:15 +0000
Subject: Re: [RFC] Safe Casting Functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-78285@lists.php.net to get a copy of this message
> On 23 Oct 2014, at 20:50, Marc Bennewitz <php@mabe.berlin> wrote: > > 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 Floats aren’t expected to be precise, so I don’t see why this shouldn’t pass. It’s a loss of data, sure, but merely of precision, which is expected here. The reason I have to_int fail is because float overflow to int completely mangles your input. -- Andrea Faulds http://ajf.me/

« previous php.internals (#78285) next »