Re: Odd and even numbers

2002-10-09 Thread Jean Padilla
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

Re: Odd and even numbers

2002-10-09 Thread Janek Schleicher
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/;

RE: Odd and even numbers

2002-10-09 Thread Nikola Janceski
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) Subject: Odd

Re: Odd and even numbers

2002-10-09 Thread Jenda Krynicky
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 numerator is

RE: Odd and even numbers

2002-10-09 Thread Jeff 'japhy' Pinyan
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