Last active
December 16, 2015 21:29
-
-
Save shyouhei/5500496 to your computer and use it in GitHub Desktop.
これだからPerlは…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zsh % carton exec perl tmp.pl | |
$VAR1 = { | |
'1.79769313486232e+308' => '1.79769313486232e+308' | |
}; | |
$VAR2 = { | |
'1.79769313486232e+308' => 'inf' | |
}; | |
zsh % bundle exec ruby tmp.rb | |
{1.7976931348623157e+308=>1.7976931348623157e+308} | |
{"1.7976931348623157e+308"=>1.7976931348623157e+308} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/perl | |
use strict; | |
use warnings; | |
use utf8; | |
use JSON::XS; | |
use Data::Dumper; | |
my $json = JSON::XS->new->utf8->allow_nonref; | |
my $val = unpack "d", "\xFF\xFF\xFF\xFF\xFF\xFF\xEF\x7F"; | |
my $hash = +{ $val => $val }; | |
my $str = $json->encode($hash); | |
my $data = $json->decode($str); | |
print Data::Dumper::Dumper($hash, $data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/ruby | |
require 'json' | |
val = "\xFF\xFF\xFF\xFF\xFF\xFF\xEF\x7F".unpack('d').first | |
hash = { val => val } | |
str = JSON.dump(hash) | |
data = JSON.parse(str); | |
p hash, data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment