Lasso Soft Inc. > Home

[lp_math_decToOctet]

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

Description

Returns an array of integer octets given a base10 integer or an array of base10 integers.

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

Sample Usage

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

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

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

	local:'return' = array;
	local:'base2' = string;
	iterate: #integer, local:'i';
		#base2 = (lp_math_dectobin: (integer:#i));
		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: #i)) - 1);
			#return->(insert: (lp_math_bintodec: #base2->(substring: (loop_count * 8) + 1, 8) ));
		/loop;
	/iterate;
	return: #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