Lasso Soft Inc. > Home

[lp_math_percentage]

Linklp_math_percentage
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted23 Dec 2005
Updated23 Dec 2005
More by this author...

Description

Returns the percentage value given the part and the total.

Requires [lp_decimal_precisionSet]

Sample Usage

Percentage Examples:

Without precision:
['[']lp_math_percentage: 2, 5[']'] = [lp_math_percentage: 2, 5]
['[']lp_math_percentage: 2, 5.82[']'] = [lp_math_percentage: 2, 5.82]
['[']lp_math_percentage: 2.73, 5[']'] = [lp_math_percentage: 2.73, 5]
['[']lp_math_percentage: 2.73, 5.82[']'] = [lp_math_percentage: 2.73, 5.82]
['[']lp_math_percentage: 67, 13[']'] = [lp_math_percentage: 67, 13]

With precision:
['[']lp_math_percentage: 2, 5, 1[']'] = [lp_math_percentage: 2, 5, 1]
['[']lp_math_percentage: 2, 5.82, 2[']'] = [lp_math_percentage: 2, 5.82, 2]
['[']lp_math_percentage: 2.73, 5, 3[']'] = [lp_math_percentage: 2.73, 5, 3]
['[']lp_math_percentage: 2.73, 5.82, 4[']'] = [lp_math_percentage: 2.73, 5.82, 4]
['[']lp_math_percentage: 67, 13, 5[']'] = [lp_math_percentage: 67, 13, 5]

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.

[

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

No comments

Please log in to comment

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft