Re: integer fail ...
- From: "Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 15:58:45 +1000
"stratus" <gis86508@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:dc9jqa$2prt$1@xxxxxxxxxxxxxxxxxxxxxxx
> $input_startx=223.0000;
> $input_starty=221.0000;
>
> $input_endx=2392.2000;
> $input_endy=2484.2000;
>
> $input_step=0.8;
>
> $total=$input_endy-$input_starty;
> $track =$total/$input_step;
> print "...$track....\n"; ====================> 2829
> $track=int $track;
> print "...$track....\n"; ====================> 2828
>
> Why ?????? 2829 changed to 2828 ???
>
>
To (partly) see why:
use warnings;
use Devel::Peek;
$input_starty=221.0000;
$input_endy=2484.2000;
$input_step=0.8;
$total=$input_endy-$input_starty;
$track =$total/$input_step;
print "############\n";
Dump($track);
print "############\n";
print "...$track....\n";
$track=int $track;
print "############\n";
Dump($track);
print "############\n";
print "...$track....\n";
__END__
Which produces for me:
############
SV = NV(0x8b09bc) at 0x8c07c8
REFCNT = 1
FLAGS = (NOK,pNOK)
NV = 2829
############
....2829....
############
SV = PVNV(0x3f8704) at 0x8c07c8
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 2828
NV = 2829
PV = 0x89304c "2829"\0
CUR = 4
LEN = 35
############
....2828....
The first time $track was printed, the NOK flag was set - so it printed the
value contained in the NV slot.
The second time $track was printed, the IOK flag was set (because the int
function had been called) - so it printed the value contained in the IV
slot.
Of course the above doesn't demonstrate how the IV slot came to contain
2828. Does someone know of a way of providing such a demonstration ?
(We can surmise that the reason the IV slot contains 2828 is that the int()
function received a value something like 2828.99999.... .
But it would be so much more conclusive if there were a way to actually
*demonstrate* that that's what happened.)
Cheers,
Rob
.
- References:
- integer fail ...
- From: stratus
- integer fail ...
- Prev by Date: Re: Perl performance issue
- Next by Date: FAQ 4.65 How can I store a multidimensional array in a DBM file?
- Previous by thread: Re: integer fail ...
- Next by thread: Re: integer fail ...
- Index(es):
Relevant Pages
|