[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Basic question from a raw recruit



I am writing a little test program to convert a tax included amount to a 
net amount. It works just fine...except if the gross amount is an even 
integer - then it returns an erroneous result. For example, if the tax is 
7% and I divide through by 1.07 ($net = $gross/1.07) and $gross = 107, I 
get a net of 9!! (instead of 100).

Now, a friend, who is an experienced programmer, but who doesn't know 
Perl, says it is because Perl is treating the number like an integer 
instead of a floating point number (probably because it IS an integer, 
having no decimal remainder).

Question: How do I tell Perl that the integer is to be treated as a 
floating  point number...I seem to recall reading that Perl treats 
integers like Floating point numbers as a matter of course, but that was 
in a Unix Perl book (Teach yourself Perl in 21 days), not a MacPerl 
manual (which I have never seen anywhere.)

Sorry to bother you all with such trivia...

Brian



**************************************************************
* Brian G Segal - astro@juliet.stfx.ca - redgull@fox.nstn.ca *
* R.R. #5  Antigonish, Nova Scotia                           *
* Canada B2G 2L3                                             *
* Phone/Fax 902-783-2772                                     *
* Home page: http://fox.nstn.ca/~redgull                     *
**************************************************************