Replies: 2 (Who?), Viewed: 294 times.
Scholar
Original Poster
#1 Old 10th Sep 2021 at 10:03 PM
Default How do you deal with divisions (and precision)?
So...

because it's too late to be brave and die young, maybe it's time to be brave and die old fool, apparently

The problem in the title is addresing pretty trivial thing, but may have non-trivial approaches. SimAnt uses integer (just like any ASM) as a fundamental numeral which is simple and fast as long as you do not need to make a proportion or divide a numeral resulting in non-integer outcome (quotient and remainder, SA by default rounds to low numeral e.g. 3/2 will always give 1 just like 16/10 will) which is fine but suboptimal if you need better precision.
Because inventing the whell once again is not very practical, an actual question: is there some established practice by experience in the matter?*

*yes I am aware about existing algorithms, including dirty ones (multiply by 10, get the last digit, compare); the point of the question is: is there a solution practical (fast, efficient with low overload) for SimAnt implementations?

Fox-Lambert (A)RL
hiatus 'till the life run again in the normal-abnormal way
favorite quote: "When ElaineNualla is posting..I always read..Nutella. I am sorry" by Rosebine
self-claimed "lower-spec simmer"
Advertisement
Lab Assistant
#2 Old 18th Sep 2021 at 7:43 AM
I've moved to doing maths with Lua for TS2, so you might want to look into that as it supports floats and you can use the SetTemp() functions to give the relevant info (as short integers) back to SimAntics. Not sure if this is the ideal solution as you're asking specifically for SimAntics, but IMO it's by far the best solution for doing messy mathematical stuff for TS2 in general.

dizzy2 has some great Lua documentation for use with TS2 if you need a resource: https://modthesims.info/showthread.php?t=248370, these have been invaluable to me.

Of course, the caveat is that it only works in post-Nightlife games.
Scholar
Original Poster
#3 Old 18th Sep 2021 at 3:35 PM
yay, thanks a lot

Fox-Lambert (A)RL
hiatus 'till the life run again in the normal-abnormal way
favorite quote: "When ElaineNualla is posting..I always read..Nutella. I am sorry" by Rosebine
self-claimed "lower-spec simmer"
Back to top