Lasso Soft Inc. > Home

[lp_math_decToBin]

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

Description

Returns a base2 string given a base10 integer.

Requires [lp_integer_bits]

Sample Usage

lp_math_dectobin: 65535,17;
'
'; lp_math_dectobin: 65536;

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_decToBin',
	-description='Returns a base2 string given a base10 integer.',
	-priority='replace',
	-required='base10', -copy,
	-optional='bits';
		
	local:'return' = string;
	#base10 = integer: #base10;
	if: !(local_defined:'bits');
		local:'bits' = (lp_integer_bits: #base10);
	/if;
	loop: -from=(integer:#bits), -to=1, -by=(-1);
		if:(#base10->(bittest:loop_count));
			#return += '1';
		else;
			#return += '0';
		/if;
	/loop;
	return: #return;

/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