Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176647
  • 博文数量: 61
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 640
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-24 23:25
文章分类

全部博文(61)

文章存档

2011年(2)

2010年(37)

2009年(22)

我的朋友

分类:

2009-06-30 14:26:18


#!/usr/bin/env perl
#
# This program is for transforming number between bin, oct, dec, hex.
#
use strict;

# decimal to binary
my $decimal = 4;
my $binary = unpack("B32", pack("N", $decimal));
print $binary, "\n";

# binary to decimal
$decimal = 4;
$binary = unpack("B32", pack("N", $decimal));
my $newdecimal = unpack("N", pack("B32", $binary));
print $newdecimal, "\n";

# decimal to oct
print sprintf "%lo\n", 16;

# oct to decimal
print oct 10, "\n";

# decimal to hex
print sprintf "%lx\n", 16;

# hex to decimal
print hex 0x1AB, "\n";

阅读(1120) | 评论(0) | 转发(0) |
0

上一篇:CF card 启动Linux

下一篇:声卡问题

给主人留下些什么吧!~~