Hi Noah,

On Tue, 08 Nov 2011 11:02:39 -0800
Noah <noah-l...@enabled.com> wrote:

> Hi there,
> 
> I am trying to round to 10 or 100 for particular values
> 
> so the following numbers
> 530
> 570
> 2330
> 2590
> 3630
> 3660
> 
> would become
> 500
> 600
> 2300
> 2600
> 3600
> 3700
> 
> any clues how to do this well?
> 

With the following program:

[CODE]
#!/usr/bin/perl

use strict;
use warnings;

foreach my $n (@ARGV)
{
    print int($n/100+0.5)*100, "\n";
}
[/CODE]

I'm getting

shlomif@telaviv1:~$ perl test.pl 530 570 2330 2590 3630 3660
500
600
2300
2600
3600
3700

So it seems to work.

Regards,

        Shlomi Fish

> Cheers,
> Noah
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/

mplayer 0.9.999.2010.03.11-rc5-adc83b19e793491b1c6ea0fd8b46cd9f32e592fc now
available for download.
    — Shlomi Fish and d3x.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to