Title: RE: problem with length()

OK. I ran this in another language.

All the answers except those that come out to 100
are longer than "6" digits including decimals.

Your program is looking for #'s <= 6 length, NOT 16

>                       if (length($speed)>6) {

but your description says you want 16 length.

>divisble by 10. It is counting any numbers not divisible by 10
>as length 16.

George

my answers for the first 10 cycles are: (skiping 0)

17.7828  15.8489  14.678  13.895  13.3352  12.9155  12.5893
31.6228  25.1189  21.5443  19.307  17.7828  16.681  15.8489
56.2341  39.8107  31.6228  26.827  23.7137  21.5443  19.9526
100  63.0957  46.4159  37.2759  31.6228  27.8256  25.1189
177.8279  100  68.1292  51.7947  42.1697  35.9381  31.6228
316.2278  158.4893  100  71.9686  56.2341  46.4159  39.8107
562.3413  251.1886  146.7799  100  74.9894  59.9484  50.1187
1000  398.1072  215.4435  138.9495  100  77.4264  63.0957
1778.2794  630.9573  316.2278  193.0698  133.3521  100  79.4328

>-----Original Message-----
>From: Shain Edge [mailto:[EMAIL PROTECTED]]
>Sent: Monday, April 26, 2004 4:00 PM
>To: perl
>Subject: problem with length()
>
>
>This program is supposed to set up colums and rows of numbers,
>much like a
>spreadsheet would look like. If the number has a length
>greater then 6 digits
>long then print a block of x's in place of the number. The
>wierd tyhing is that
>with the program below, it only correctly prints prints
>numbers that are
>divisble by 10. It is counting any numbers not divisible by 10
>as length 16.
>
>Can anyone show me where I'm going wrong?
>
>Shain
>
>-----------------------------------
>
>for ($a = 0.0; $a <= 40; ++$a) {
>       print sprintf("%2d",$a);
>       for ($b=4.0; $b<=10; $b++) {
>               if ($a==0) {
>                       print sprintf(" %6d", $b); #display
>power levels in colums for each $b
>               } else {
>                       $speed = 10*10**( ($a-1)/$b );
>                       if (length($speed)>6) {
>                               print sprintf(" x%4dx",
>length("$speed"));
>                       } else {
>                               print sprintf(" %6d", $speed);
># display speed in even colums for each $b
>                       }
>               }
>       }
>       print "\n"; # End row
>}
>
><STDIN>
>
>=====
>Mekton Compendium: http://groups.yahoo.com/group/mekton-c/
>Subscribe: http://groups.yahoo.com/subscribe/mekton-c
>
>Nothing is impossible. the supposidly impossible can be made
>possible by anyone who determines what you need to do to make
>it a reality. -Shain Edge
>
>
>      
>              
>__________________________________
>Do you Yahoo!?
>Yahoo! Photos: High-quality 4x6 digital prints for 25¢
>http://photos.yahoo.com/ph/print_splash
>_______________________________________________
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to