Re: integer fail ...



stratus <gis86508@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> $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


change your print() statements to:

printf "...%30.20f....\n", $track;

....

> Why ?????? 2829 changed to 2828 ???

.... and you will see why. :-)



Then see the answer to your Frequently Asked Question:

Why am I getting long decimals (eg, 19.9499999999999) instead of the
numbers I should be getting (eg, 19.95)?


And you might also benefit from this FAQ:

Does Perl have a round() function? ...


--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.



Relevant Pages