Lasso Soft Inc. > Home

[lp_math_decToHex]

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

Description

Returns a base16 string given a base10 integer.

Requires [lp_string_pad]

Sample Usage

loop: -from=0, -to=30;
	loop_count ' ' (lp_math_dectohex: loop_count) '
'; /loop;

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

	// http://www.danbbs.dk/~erikoest/hex.htm
	
	local:'base16'= string;

	// hex chars
	local:'hex_list'='0123456789ABCDEF';

	#base10 = integer: #base10;
	
	while: #base10 > 0;
		#base16 = #hex_list->(get: (#base10 % 16) + 1) + #base16;
		#base10 = math_floor: (#base10 / 16);
	/while;

	// return base16 number
	return: (lp_string_pad: #base16, 2, '0');

/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