Mr.T Mr.X wrote: > Well, first of all, I am replying to this address, because everytime I try to send > an email to the "group" i get it returned. > Where am I supposed to send my questions? Well, in case its here, heres my Q: > > I am trying to work my way through the "Teach yourself PERL in 24 > hours" book, and at the end of chapter 2, it asks to make a number: > 24.325613832 - change to only 2 decimal places (24.33) So, how can I do this > without using the printf command, (as the book asks to do it without > using the printf command)?
This is my private mail address. Post to the list by mailing to the address [EMAIL PROTECTED] I have forwarded this mail there. >From your subject line it sounds like you know the answer already. If you multiply the value up so that all the digits you want are to the left of the decimal point then you can use 'int' before scaling it back. my $val = 24.325613832; print int ($val * 100) / 100; OUTPUT 24.32 You question says the result should be 24.33, which is wrong - this would involve rounding as well. If that's what you want, then think how you could transform all values from 24.325 to 24.335 to something between 2433.0 and 2433.99. Then you can use 'int' like I did above and reverse the scaling. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]