[lp_decimal_precisionSet]

Description

Link: [lp_decimal_precisionSet]
Author: Bil Corry
Category: Math
Version: 8.x
License: Public Domain
Posted: Nov. 21, 2005
Updated: Dec. 05, 2005
More by this author...
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]

Parameters

-number decimal, required Number to format
-precision integer, optional Precision (number of decimal places) - default is all significant digits

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[

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

none

Email:


Password:



Newest

Most Popular