Thanks Felix. I actually used $start_discounted_gift_cert = ($total_start) * ($start_discounted_gift_cert_of_total); $start_discounted_gift_cert = sprintf("%8.2f",$start_discounted_gift_cert);
$giftcert_remainder_first = substr($start_discounted_gift_cert, -5); $giftcert_remainder_first = sprintf("%8.2f",$giftcert_remainder_first); substr() works perfectly. Even though substr() works well, i believe that it was created to be used with strings not numbers. I know that you are all busy, but can anyone point out anything fundamentally wrong with my approach? Thanks, Andrew -----Original Message----- From: Felix Geerinckx [mailto:felix_geerinckx@;hotmail.com] Sent: Thursday, October 17, 2002 3:06 PM To: [EMAIL PROTECTED] Subject: Re: replacing numbers around a decimal 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]