On Oct 9, Nikola Janceski said:
>perl -e 'printf "%.0d\n", $ARGV[0]/2 if @ARGV' 5
>
>Weird why doesn't this work they way I expect it to?
>it returns 2 not 3.
Blame C and the IEEE standards.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734
$x++ if $x%2;
This increments $x if $x is odd.
Shawn
robert.zielfelder@tycoelect
From: "Zielfelder, Robert"
<[EMAIL PROTECTED]>
> I am trying to write a script that at one point needs to look at a
> number and divide it by two. The results must always be an integer,
> but the numerator can potentially be an odd number. What I want to do
> is if the numerat
perl -e 'printf "%.0d\n", $ARGV[0]/2 if @ARGV' 5
Weird why doesn't this work they way I expect it to?
it returns 2 not 3.
> -Original Message-
> From: Zielfelder, Robert
> [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 09, 2002 10:58 AM
> To: Perl Beginners List (E-mail)
> Subje
Robert Zielfelder wrote:
> I am trying to write a script that at one point needs to look at a number
> and divide it by two. The results must always be an integer, but the
> numerator can potentially be an odd number.
So you just want to divide by 2 rounding up the result.
use POSIX qw/ceil
Hi,
$num += $num % 2;
this increments $num if $num modulo 2 is 1
(ie. if $num was odd)
regards.
"Zielfelder, Robert" a écrit :
>
> Greetings,
>
> I am trying to write a script that at one point needs to look at a number
> and divide it by two. The results must always be an integer, but the