Re: math functions

by "Keith D Sellars" <Keith(at)webgraffix.com>

 Date:  Fri, 11 Apr 2003 18:40:06 -0400
 To:  <hwg-languages(at)hwg.org>
 References:  S0026260871 RYAN
  todo: View Thread, Original
  $x .= .5 * $b * ((($a + (.25 * ($f - 25))) + $d + $e) * (1 + $g));

Above is the code I finally came up with that generates the correct prices
for any combination that you may choose from the page
(https://www.webgraffix.com/postsearchlight/Classifieds2.php).  I have
tested it pretty thoroughly, but would welcome any scenarios where anyone
found a combination of options that did not work.

I have one question - How do I round off a value to say, 2 digits.  For
instance, if you choose the Commercial Liner, 1 Insertion and 1 Week to run,
as well as 50 words total with 2 italicized and All Caps, then the price is
$36.375.  How would I take the value of "x" and round it off so that I have
2 digits after the decimal point?

Thanks,
Keith D Sellars
WebGraffix
www.webgraffix.com

"Making database sites seem easy"

----- Original Message -----
From: "Ryan Fischer" <ryan(at)gigabee.com>
To: "Keith D Sellars" <Keith(at)webgraffix.com>; <hwg-languages(at)hwg.org>
Sent: Friday, April 11, 2003 5:55 PM
Subject: Re: math functions


> > Hi guys,
> >
> > I have a form on which I wish to do a simple calculation in php.
> >
> > Here is what I need to do:
> >
> > x = [a + .25(f-25)) + d + e] * [1 + g]  all divided by 2  (or
> multiplied by
> > .5 whichever is easiest coding)
> >
> > Here is a link so you can see what I'm trying to accomplish.  I've
> created a
> > mathematical formula (above), that works correctly if I can just
> duplicate
> > it in the appropriate php code.
> >
> > https://www.webgraffix.com/postsearchlight/Classifieds2.php
> >
> > I know it's probably a simple thing, but I keep running into errors
> when I
> > try to do it.  Any help would be greatly appreciated.
>
> Use parenthesis where needed:
>
> $x = (($a + (.25 * ($f - 25))) + $d + $e) * (1 + $g)) / 2;
>     // or * .5; it doesn't matter
>
> HTH!
>
> -Ryan Fischer
>
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.