Lasso Soft Inc. > Home

[lp_math_binToDec]

Linklp_math_binToDec
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted05 Dec 2005
Updated05 Dec 2005
More by this author...

Description

Returns a base10 integer given a base2 string.

Sample Usage

lp_math_bintodec: '01111111111111111';
'
'; lp_math_bintodec: '10000000000000000';

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_binToDec',
		-description='Returns a base10 integer given a base2 string.',
		-priority='replace',
		-required='base2';

	// init base10
	local:'base10'= integer: 0;
	
	// cycle through binary number
	iterate: (string:#base2), local:'digit';
		#base10 = (#base10 * 2) + (integer: #digit);
	/iterate;
	
	// return base10 number
	return: #base10;
	
/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