Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-25 Thread Andrea Faulds
Hi, Marc Bennewitz wrote: It's totally true that on casting non numeric string to integer will result in 0 but that's a different type even if it's also a numeric type. From my understanding PHP tries to cast from one type to another by loosing as less information as possible. In this case I s

Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-24 Thread Marc Bennewitz
Hi Andrea, Am 24.10.2016 um 15:40 schrieb Andrea Faulds: Hi, Marc Bennewitz wrote: But I'm still curious why casting any non numeric string results in the valid number float(0) where there is a special value in floating point numbers declared to represent not a number values. Because that's

RE: [PHP-DEV] strtod and NaN vs. zero

2016-10-24 Thread Anatol Belski
Hi Marc, > -Original Message- > From: Marc Bennewitz [mailto:dev@mabe.berlin] > Sent: Sunday, October 23, 2016 12:56 PM > To: PHP Internals List > Subject: [PHP-DEV] strtod and NaN vs. zero > > Hi internals, > > On casting a non numeric value to a float in P

Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-24 Thread Andrea Faulds
Hi, Marc Bennewitz wrote: But I'm still curious why casting any non numeric string results in the valid number float(0) where there is a special value in floating point numbers declared to represent not a number values. Because that's what C's strtod() does, and it's also what (int) does (be

Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-23 Thread Marc Bennewitz
Am 23.10.2016 um 21:13 schrieb Marc Bennewitz: Am 23.10.2016 um 13:49 schrieb Niklas Keller: 2016-10-23 12:55 GMT+02:00 Marc Bennewitz mailto:dev@mabe.berlin>>: Hi internals, On casting a non numeric value to a float in PHP the result will be float(0). In PHP-7.0 an except

Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-23 Thread Marc Bennewitz
Am 23.10.2016 um 13:49 schrieb Niklas Keller: 2016-10-23 12:55 GMT+02:00 Marc Bennewitz mailto:dev@mabe.berlin>>: Hi internals, On casting a non numeric value to a float in PHP the result will be float(0). In PHP-7.0 an exception was introduced that on casting a string "/

Re: [PHP-DEV] strtod and NaN vs. zero

2016-10-23 Thread Niklas Keller
2016-10-23 12:55 GMT+02:00 Marc Bennewitz : > Hi internals, > > On casting a non numeric value to a float in PHP the result will be > float(0). > > In PHP-7.0 an exception was introduced that on casting a string > "/\s*NaN\s*/i" will result in float(NaN). > > https://3v4l.org/2Xakm > > Wouldn't it

[PHP-DEV] strtod and NaN vs. zero

2016-10-23 Thread Marc Bennewitz
Hi internals, On casting a non numeric value to a float in PHP the result will be float(0). In PHP-7.0 an exception was introduced that on casting a string "/\s*NaN\s*/i" will result in float(NaN). https://3v4l.org/2Xakm Wouldn't it be more logical and expected to return NaN in all cases o