Perl 数值标量


标量通常是数字或字符串。以下示例展示了各种类型数值标量的使用方式:

示例

 演示

#!/usr/bin/perl
$integer = 200;
$negative = -300;
$floating = 200.340;
$bigfloat = -1.2E-23;
# 377 octal, same as 255 decimal
$octal = 0377;
# FF hex, also 255 decimal
$hexa = 0xff;

print "integer = $integer\n";
print "negative = $negative\n";
print "floating = $floating\n";
print "bigfloat = $bigfloat\n";
print "octal = $octal\n";
print "hexa = $hexa\n";

输出

将产生以下结果:

integer = 200
negative = -300
floating = 200.34
bigfloat = -1.2e-23
octal = 255
hexa = 255

更新时间:2019 年 11 月 28 日

140 次浏览

开启你的 职业生涯

完成课程即可获得认证

开始
广告
© . All rights reserved.