> Abs()

I use Abs() for comparing if numbers are "reasonably" close

<CFIF abs(a - b) LT .05>

> Sgn()

I've had situations where I calculated a value and then had to decide if I
were to add or subtract that amount based on the sign of some other
variable. Rather than do
<CFIF x GT 0><CFSet a = b + c><CFElse><CFSet a = b - c></CFIF>
I've done <CFSet a = b + sgn(x) * c>

> Log()

Log can be very useful in solving equations involving exponents. Seems like
there was a CF-Talk post recently where Log was used in the solution, but I
don't remember what it was.

I've used Log() for statistical calculations like fitting a line to a series
of data points when the line was some type of curve rather than a straight
line.

> ACos()
> ASin()
> Atn() (or otherwise referred to as Atan)
> Cos()
> Sin()
> Tan()
> Pi()

I have had little reason to use trig functions or PI in business
programming. The only application I've had was zipcode distance
calculations.

<CFSET Temp = sin(Latitude1) * sin(Latitude2 * pi()/180) +
        cos(Latitude1) * cos(Latitude2 * pi()/180) *
        cos(Longitude2 * pi()/180 - Longitude1)>
<CFIF temp is 1>
        <CFSet Mileage = 0>
<CFElse>
        <CFSET Mileage = 3963.0 * (ATN(-Temp / SQR(-Temp * Temp + 1))
        + 1.570796326794895)>
        <CFSet Mileage = Round(Mileage * 100) / 100>
</CFIF>

Hope this helps.

Chris

---------------------------------------------------
Christopher P. Maher
mailto:[EMAIL PROTECTED]
Maher Associates, Inc.
Actuarial and Computer Consulting
http://www.maherassociates.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to