Don Dukelow wrote:

I have a script where I have to divide and all I want is the hole
number, not the decimal point.
When I do
$num = 2;
$count = 49;
$count /= $num;

$count comes out 24.5, I thought I would get 24.  If I wanted the
remainder I WOULD DO.

$count %= $num;  which does work.  When did Perl start giving 24.5 for a
answer.

I can do
$count = sprint "%d", ($count /= $num);

and this works.  But every other language I've programmed in anything
dividing with "/" you only get the hole number why?

Hello Don

You seem very indignant that Perl is offering you a floating-point result -
it started giving 24.5 right at the beginning of its life! What are these
languages you have used that give only an integer result for division? I
can think of none off the top of my head. What do they return if you ask
for 4/12*9?

If you only ever want to do integer arithmetic just add the line

use integer;

on a line at the start of your program.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to