小编ftu*_*msh的帖子

perl整数运算给出浮点答案

以下代码模仿实际的生产代码.双引号用作来自XML文件的实际数据,使用XML:Twig以下方法解析:

#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;
use Devel::Peek;

my $linetotalinclusive = "8458.80" * 1_000_000;

$linetotalinclusive = $linetotalinclusive;

my $c = "7980.00" * 1_000_000;

my $data = $linetotalinclusive - $c;

print Dump $c;

print Dump $linetotalinclusive;

print "$linetotalinclusive - $c = $data \n";
Run Code Online (Sandbox Code Playgroud)

给出以下结果:

SV = PVNV(0x22885f0) at 0x21984f8
  REFCNT = 1
  FLAGS = (PADMY,IOK,NOK,pIOK,pNOK)
  IV = 7980000000
  NV = 7980000000
  PV = 0
SV = PVNV(0x2288650) at 0x21984c8
  REFCNT = 1
  FLAGS = (PADMY,NOK,pIOK,pNOK)
  IV = …
Run Code Online (Sandbox Code Playgroud)

floating-point perl integer integer-arithmetic

4
推荐指数
1
解决办法
218
查看次数