LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1227|回复: 3

怎么比较浮点数?

[复制链接]
发表于 2004-4-16 22:49:06 | 显示全部楼层 |阅读模式
这是我的练习,怎么总出错?[php]
/home/javalee#perl -
$a="1.2345";$b="1.2354"
if($a > $b){print "a is big"}else{print "a is small"};print "\n";__END__
syntax error at - line 2, near "){"
Execution of - aborted due to compilation errors.[/php]
[php]
/home/javalee#perl -
$a=4;$b=3
if($a > $b){print "a is big"}else{print "a is small"};print "\n";__END__
syntax error at - line 2, near "){"
Execution of - aborted due to compilation errors.
/home/javalee#[/php]
这是怎么回事?...:thank
perl version

  1. /home/javalee#perl -e 'print "$]\n"'
  2. 5.008
复制代码
 楼主| 发表于 2004-4-16 23:21:09 | 显示全部楼层
奇怪,又可以了 :ask
[php]
/home/javalee#perl -
$a=4;$b=5;
if($a>$b){print "ok\n"}else{print "error\n"};__END__
error
/home/javalee#perl -
$a=4.444;$b=4.445;
if($a>$b){print "ok\n"}else{print "error\n"};__END__
error
[/php]
发表于 2004-4-17 09:23:04 | 显示全部楼层
$a=4;$b=3
$a=4;$b=5;

仔细看看这两行有什么区别。

你编程的习惯太差,我建议你看一下perlstyle。初学时,养成良好习惯很重要。
 楼主| 发表于 2004-4-17 10:18:32 | 显示全部楼层
最初由 BBDD 发表
$a=4;$b=3
$a=4;$b=5;

仔细看看这两行有什么区别。

你编程的习惯太差,我建议你看一下perlstyle。初学时,养成良好习惯很重要。

谢谢指教!以后还要向高手请教!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表