lemming Posted February 10, 2006 Report Share Posted February 10, 2006 I needed a quick-and-dirty Modulo calculation so I just wrote this from scratch. Here's my macro which works as a basic calculator. Modulo operation as defined in Wikipedia In computing, the modulo operation finds the remainder of division of one number by another. Given two numbers, a and n, a modulo n (abbreviated as a mod n) is the remainder, on division of a by n. To calculate: a mod n a - n (floor( a / n )) This macro has only been lightly tested, but it appears to work for me. The macro returns the same results as the Modulo function in Win XP's Calculator (Scientific view). Of course, you can also get a Modulo (Mod) function from PG Macros: http://www.pgmacros.com/math_and_science.htm But I didn't want to install PG Macros just for one function. Modulo_calc.mex Quote Link to comment Share on other sites More sharing options...
joe Posted February 16, 2006 Report Share Posted February 16, 2006 Perfect! The one in our PGM Functions Library uses Decimals %Dxx% and extra step to extract just the whole number. The { Math - Mod } function was created before Macro Express had the ability to mix Integers and Decimals in a single calculation. Speaking of fun things, the { Math - Square Root } function was done with native Macro Express code using a "divide and average" method ... it must have been a day when I had a lot of time on my hands Quote Link to comment Share on other sites More sharing options...
lemming Posted February 21, 2006 Author Report Share Posted February 21, 2006 Heh, "divide and average" aka the Babylonian method. Seems tedious, but doable. Hopefully, I won't need to do square root calculations anytime soon. Note to other users - PG Macros is the easier route. Quote Link to comment Share on other sites More sharing options...
joe Posted February 22, 2006 Report Share Posted February 22, 2006 I'm sure the Babylonians had a lot of time on their hands, except for that tower thing. But really, what was else was there to do except Macro Express coding on a hot Saturday night in the desert? Quote Link to comment Share on other sites More sharing options...
paul Posted February 22, 2006 Report Share Posted February 22, 2006 Sorry to have to correct Joe on this, but I feel sure it was a Sunday! And it wasn't that hot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.