Lasso Soft Inc. > Home

[lp_decimal_precisionSet]

Linklp_decimal_precisionSet
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted21 Nov 2005
Updated05 Dec 2005
More by this author...

Description

Returns a decimal number formatted to the specified precision.  If precision is omitted, the default is to show all significant digits.

Note: Requires [lp_decimal_precisionGet]

Sample Usage

[lp_decimal_precisionSet: 9.12345, 3]

Returns:

9.123

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_decimal_precisionSet',
	-description='Returns a decimal number formatted to the specified precision.',
	-priority='replace',
	-required='number', -copy,
	-optional='precision';

	// make sure number is a decimal
	#number = decimal: #number;	

	// did we get a precision?
	if:!(local_defined:'precision');
		// nope, set it to show all significant digits
		local:'precision' = (lp_decimal_precisionGet: #number);
	/if;
	
	// format the number
	#number->(setformat: -precision=(integer:#precision));

	// return
	return: #number;

/define_tag;

]

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

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