Like most programming languages, Lua loses mathematical precision after a certain point, which can be problematic for certain applications, one of which I was reminded of today when looking at something else. SO, I wrote a script to attempt to handle "very large numbers" accurately. Basically, it makes a class for these numbers and attempts to implement all of the mathematical operators (+, -, *, /, %, ^) and comparative operators (<, >, <=, >=, ==, ~=). Right now, there are some fairly significant limitations to this script, namely that it only handles integers, and you can only use non-negative integer powers when using the ^ operator. I'm slowly figuring out a method for effectively including decimals, though to avoid blowing up computers I'll naturally have to limit precision when dividing (since 1/3 produces an infinitely long number, and we just don't have room for that), though I think I'll be able to make the precision something you can select if you care to. Also, I would LIKE to be able to exponents that aren't strictly non-negative integers, but I'm how to implement that at this point (I would LOVE to hear ideas for algorithms to calculate them).
Anyway, here is what I have so far:
Share your scripts and packages with other Mudlet users.
2 posts • Page 1 of 1