Link | math_roundto |
Author | Jason Huck |
Category | Math |
Version | 8.5.x |
License | Public Domain |
Posted | 19 May 2007 |
Updated | 24 May 2007 |
More by this author... |
Given two numbers, rounds the first number to the closest multiple of the second number.
math_roundto(51, 5); -> 50 math_roundto(53, 5); -> 55
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( 'roundto', -namespace='math_', -req='n', -req='m', -priority='replace', -description='Rounds the first number to the closest multiple of the second number.' ); local('nxt') = #n - (#n % #m) + #m; local('lst') = #nxt - #m; local('avg') = (#nxt + #lst) / 2.0; if(#n % #m); local('out') = (#n >= #avg ? #nxt | #lst); else; local('out') = #n; /if; return(#out); /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft