Std.parseInt and Std.parseFloat different behaviors

48 views
Skip to first unread message

Francis Bourre

unread,
Jun 29, 2016, 1:34:13 AM6/29/16
to Haxe
Hi.

Any idea why this returns 5 and not NaN ?
Std.parseFloat( "5g" );

While this returns null and not 5 ?
Std.parseInt( "5g" );

I mean is it intended for good reasons ?
I only tested it with JS target.

Juraj Kirchheim

unread,
Jun 29, 2016, 3:48:42 AM6/29/16
to haxe...@googlegroups.com
On Wed, Jun 29, 2016 at 7:34 AM, Francis Bourre <peter...@gmail.com> wrote:
Hi.

Any idea why this returns 5 and not NaN ?
Std.parseFloat( "5g" );

While this returns null and not 5 ?
Std.parseInt( "5g" );

Are you sure? This should actually return 5: http://try.haxe.org/#eA639 

I mean is it intended for good reasons ?
I only tested it with JS target.


So there's probably something rather weird going on on your end ;)

Best,
Juraj 

Francis Bourre

unread,
Jun 29, 2016, 4:37:40 AM6/29/16
to Haxe
Thanks, you're right, I omitted a conditional compiled block. :)
Reply all
Reply to author
Forward
0 new messages