on wo, 16 okt 2002 20:03:31 GMT, Andrew Hughes wrote:

> I am creating a little calculator that is going to need to take a
> user entered number that will always have 2 decimal places (using
> sprintf).  It could be 89562321.29 or it could be 101.00) and take
> the last 4 digits (with the period included, so five places) and do
> two things: 
> 
> 1)Store the number in a variable.  For the two examples above that
> would be 21.29 and 01.00 respectively would be stored in their own
> variable x=21.29 or it could be x=01.00; and 
> 
> 2) replace the last 4 numbers (5 places) with 00.00 -- always.  For
> the two examples above they would become 89562300.00 and 100.00.  Can
> anyone point me in the right direction?


my $number = 89562321.29;

my $big = int($number/100)*100;
my $small = $number - $big;

printf("%.2f - %05.2f\n", $big, $small);

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to