Lasso Soft Inc. > Home

[lp_math_hexToBin]

Linklp_math_hexToBin
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted06 Dec 2005
Updated06 Dec 2005
More by this author...

Description

Returns a base2 string given a base16 string.

Sample Usage

lp_math_hextobin: 'ABCD'; // 1010101111001101

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_hexToBin',
	-description='Returns a base2 string given a base16 string.',
	-priority='replace',
	-required='base16', -copy;

	// http://www.danbbs.dk/~erikoest/hex.htm

	#base16 = string: #base16;
	local:'base16_len' = #base16->length;	
	local:'base2' = string;
	local:'conversion' = (map:
							'0' = '0000',
							'1' = '0001',
							'2' = '0010',
							'3' = '0011',
							'4' = '0100',
							'5' = '0101',
							'6' = '0110',
							'7' = '0111',
							'8' = '1000',
							'9' = '1001',
							'A' = '1010',
							'B' = '1011',
							'C' = '1100',
							'D' = '1101',
							'E' = '1110',
							'F' = '1111'
						);
	
	iterate: #base16, local:'i';
		#base2 += #conversion->(find: #i);
	/iterate;

	return: #base2;

/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