Well, let's use a language with better bigint support. Yes, I know
about Math::BigInt, but others will tell you about that anyway,
so I'll show other solutions. For these,
you have to install respective software
(dc, bc, ruby)
if you don't already have it.
perl -we '"38"=~/(-?)(\d+)/ and $decimal = ($1?"_":"").$2; `dc -e 2o${
+decimal}p` =~ /(-?[01]+)/ and $binary = $1; print $binary, "\n";'
perl -we '"9007199254740991"=~/(-?\d+)/ and $decimal = $1; `echo obase
+=2\\;${decimal} | bc` =~ /(-?[01]+)/ and $binary = $1; print $binary,
+ "\n";'
perl -we '"9007199254740991"=~/(-?\d+)/ and $decimal = $1; `ruby -e\47
+printf(%[%b],\$*[0])\47 ${decimal}` =~ /(-?[01]+)/ and $binary = $1;
+print $binary, "\n";'
|