Lasso Soft Inc. > Home

[lp_math_octetToDec]

Linklp_math_octetToDec
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted17 Jan 2006
Updated17 Jan 2006
More by this author...

Description

Returns a base10 integer given an array of integer octets.

Requires: [lp_math_dectobin] [lp_string_pad] [lp_integer_bytes] [lp_math_bintodec]

Sample Usage

lp_math_octettodec: (array: 195, 164); // returns 50084

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_octetToDec',
	-description='Returns a base10 integer given an array of integer octets.',
	-priority='replace',
	-required='bytes', -copy;

	if: #bytes->type != 'array';	
		#bytes = (array: (integer: #bytes));
	/if;

	local:'return' = string;
	local:'base2' = string;
	iterate: #bytes, local:'byte';
		#base2 = (lp_math_dectobin: (integer:#byte));
		if: #base2->size % 8 > 0;
			#base2 = (lp_string_pad: #base2, (#base2->size + (8 - (#base2->size % 8))) ,'0');
		/if;
		loop: -from=0, -to=((lp_integer_bytes: (integer: #byte)) - 1);
			#return += #base2->(substring: (loop_count * 8) + 1, 8);
		/loop;
	/iterate;
	return: (lp_math_bintodec: #return);

/define_tag;

]

Related Tags

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