On Sep 1, 5:03 pm, [EMAIL PROTECTED] (Rodrigo Tavares) wrote:
> Hello,
>
> I have a problem with a counter.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> print "Write a number:";
> my $number= ;
>
> my @array;
> my $div = $number * 2 ;
> my $i=0;
>
> while ($div > 0)
> {
> $div = $div
On 9/1/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote:
snip
> Write a number:23
> Value i is : 1081
> 23
> 11.5
> 5.75
> 2.875
> 1.4375
>
> Why did script show the value ?
>
> The counter must be six.
snip
Sounds like you want integer math rather than floating point math. In
floating point math re
Rightly said by Gunnar. To see all the values stored in @array add:
foreach (@array)
{
print "$_\n";
}
On 9/2/07, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:
>
> Rodrigo Tavares wrote:
> > Hello,
> >
> > I have a problem with a counter.
> >
> > #!/usr/bin/perl
> >
> > use strict;
> > use warn
Rodrigo Tavares wrote:
Hello,
I have a problem with a counter.
#!/usr/bin/perl
use strict;
use warnings;
print "Write a number:";
my $number= ;
my @array;
my $div = $number * 2 ;
my $i=0;
while ($div > 0)
{
$div = $div / 2;
$array[$i]=$div;
$i++;
}
print "Value i is: $i\n";
pr