Re: integer fail ...
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 07:46:20 -0500
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
.
- References:
- integer fail ...
- From: stratus
- integer fail ...
- Prev by Date: Re: Problem with enqueuing/dequeuing objects between threads
- Next by Date: Re: FAQ 4.67 Why does passing a subroutine an undefined element in a hash create it?
- Previous by thread: Re: integer fail ...
- Next by thread: FAQ 4.24 How do I reverse a string?
- Index(es):
Relevant Pages
|
|