[lp_math_percentage]

Description

Link: [lp_math_percentage]
Author: Bil Corry
Category: Math
Version: 8.x
License: Public Domain
Posted: Dec. 23, 2005
Updated: Jan. 01, 0001
More by this author...
Returns the percentage value given the part and the total.

Requires [lp_decimal_precisionSet]

Parameters

-part decimal, required The part of the total.
-total decimal, required The total.
-precision integer, optional The precision to use for the percentage returned. Default is 0.

Sample Usage

<pre>
<b>Percentage Examples:</b>

Without precision:
['[']lp_math_percentage: 2, 5[']'] = <b>[lp_math_percentage: 2, 5]</b>
['[']lp_math_percentage: 2, 5.82[']'] = <b>[lp_math_percentage: 2, 5.82]</b>
['[']lp_math_percentage: 2.73, 5[']'] = <b>[lp_math_percentage: 2.73, 5]</b>
['[']lp_math_percentage: 2.73, 5.82[']'] = <b>[lp_math_percentage: 2.73, 5.82]</b>
['[']lp_math_percentage: 67, 13[']'] = <b>[lp_math_percentage: 67, 13]</b>

With precision:
['[']lp_math_percentage: 2, 5, 1[']'] = <b>[lp_math_percentage: 2, 5, 1]</b>
['[']lp_math_percentage: 2, 5.82, 2[']'] = <b>[lp_math_percentage: 2, 5.82, 2]</b>
['[']lp_math_percentage: 2.73, 5, 3[']'] = <b>[lp_math_percentage: 2.73, 5, 3]</b>
['[']lp_math_percentage: 2.73, 5.82, 4[']'] = <b>[lp_math_percentage: 2.73, 5.82, 4]</b>
['[']lp_math_percentage: 67, 13, 5[']'] = <b>[lp_math_percentage: 67, 13, 5]</b>
</pre>
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[

define_tag:'lp_math_percentage',
	-description='Returns the percentage value given the part and the total.',
	-priority='replace',
	-required='part',
	-required='total',
	-optional='precision';

	// did we get a precision?
	if:!(local_defined:'precision');
		// nope, set it to zero
		local:'precision' = 0;
	/if;

	// return the percentage
	return: (lp_decimal_precisionSet: (decimal: (decimal:#part) / (decimal:#total) * (decimal:100)), (integer:#precision));

/define_tag;
     
]

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net