sysread / TOML-Tiny

A minimal TOML parser and serializer for perl 5
8 stars 6 forks source link

The value '!!0' is output as 'nan' #29

Closed djerius closed 2 months ago

djerius commented 5 months ago

Howdy,

This is a bit odd:

% perl -MTOML::Tiny=to_toml -E 'say to_toml(!!0)'
nan
% perl -v

This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux_RHEL-8-thread-multi

% perl -MTOML::Tiny -E 'say TOML::Tiny->VERSION'
0.16
djerius commented 5 months ago

Looking at the code, it's the result of this:

% perl -MMath::BigFloat -E 'say Math::BigFloat->new(!!0)->is_nan';
1

And TBH, I'm not sure exactly what the result should be for that operation.

perlpunk commented 2 months ago

I created #31, so at least for newer perl versions it would do the right thing. Hard to say if it can be improved for older versions.