Skip to content

Instantly share code, notes, and snippets.

@shyouhei
Last active December 16, 2015 21:29
Show Gist options
  • Save shyouhei/5500496 to your computer and use it in GitHub Desktop.
Save shyouhei/5500496 to your computer and use it in GitHub Desktop.
これだからPerlは…
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}
#! /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);
#! /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