Link | lp_math_mod |
Author | Bil Corry |
Category | Math |
Version | 8.x |
License | Public Domain |
Posted | 12 Feb 2006 |
Updated | 12 Feb 2006 |
More by this author... |
Returns the modulo given a numerator and denominator. Works around LP8.1 math_mod that returns string type and it works around LP8.1 mod operator '%' that only works with integers.
Note that this implements "truncation towards zero" which is technically not modulo, but more in line with what most people expect.
More info here: http://mathforum.org/library/drmath/view/52343.html
Requires [lp_decimal_precisionset] [lp_decimal_fixed]
lp_math_mod: 10.5, 2; // 0.5
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_mod', -description='Returns the modulo given a numerator and denominator.', -priority='replace', -required='numerator', -required='denominator'; // works around LP8.1 math_mod that returns string type // and it works around LP8.1 mod operator '%' that only works with integers // note that this implements "truncation towards zero" which is technically not modulo, but more in line with what most people expect // more info here: http://mathforum.org/library/drmath/view/52343.html return: (lp_decimal_precisionset: (decimal: #numerator) - (decimal: #denominator) * (lp_decimal_fixed: (decimal: #numerator) / (decimal: #denominator))); /define_tag; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft